app/soc/logic/key_name.py
changeset 522 c06a009005fc
parent 512 aae25d2b4464
equal deleted inserted replaced
521:07b2c382a4d6 522:c06a009005fc
    29 class Error(Exception):
    29 class Error(Exception):
    30   """Base class for all exceptions raised by this module."""
    30   """Base class for all exceptions raised by this module."""
    31   pass
    31   pass
    32 
    32 
    33 
    33 
    34 def nameDocument(partial_path, link_id=None):
    34 def nameDocument(scope_path, link_id=None):
    35   """Returns a Document key name constructed from a path and link ID.
    35   """Returns a Document key name constructed from a path and link ID.
    36     
    36     
    37   Args:
    37   Args:
    38     partial_path: the first portion of the path to the Document that uniquely
    38     scope_path: the first portion of the path to the Document that uniquely
    39       identifies it
    39       identifies it
    40     link_id: optional link ID to append to path (when omitted,
    40     link_id: optional link ID to append to path (when omitted,
    41       partial_path is actually the entire path, with the link_id already
    41       scope_path is actually the entire path, with the link_id already
    42       appended)
    42       appended)
    43 
    43 
    44   Raises:
    44   Raises:
    45     Error if partial_path and link_id produce a "False" path (None,
    45     Error if scope_path and link_id produce a "False" path (None,
    46     empty string, etc.)
    46     empty string, etc.)
    47   """
    47   """
    48   path = [partial_path]
    48   path = [scope_path]
    49   
    49   
    50   if link_id:
    50   if link_id:
    51     path.append(link_id)
    51     path.append(link_id)
    52 
    52 
    53   path = path_link_name.combinePath(path)
    53   path = path_link_name.combinePath(path)
    56     raise Error('"path" must be non-False: "%s"' % path)
    56     raise Error('"path" must be non-False: "%s"' % path)
    57 
    57 
    58   return 'Document:%s' % path
    58   return 'Document:%s' % path
    59 
    59 
    60 
    60 
    61 def nameSiteSettings(partial_path, link_id):
    61 def nameSiteSettings(scope_path, link_id):
    62   """Returns a SiteSettings key name constructed from a supplied path.
    62   """Returns a SiteSettings key name constructed from a supplied path.
    63   
    63   
    64   Raises:
    64   Raises:
    65     Error if path is "False" (None, empty string, etc.)
    65     Error if path is "False" (None, empty string, etc.)
    66   """
    66   """
    67 
    67 
    68   if not partial_path:
    68   if not scope_path:
    69     raise Error('"partial_path" must be non-False: "%s"' % partial_path)
    69     raise Error('"scope_path" must be non-False: "%s"' % scope_path)
    70 
    70 
    71   if not link_id:
    71   if not link_id:
    72     raise Error('"link_id" must be non-False: "%s"' % link_id)
    72     raise Error('"link_id" must be non-False: "%s"' % link_id)
    73 
    73 
    74   return 'SiteSettings:%s:%s' % (partial_path, link_id)
    74   return 'SiteSettings:%s:%s' % (scope_path, link_id)
    75 
    75 
    76 
    76 
    77 def nameHomeSettings(partial_path, link_id):
    77 def nameHomeSettings(scope_path, link_id):
    78   """Returns a HomeSettings key name constructed from a supplied path.
    78   """Returns a HomeSettings key name constructed from a supplied path.
    79 
    79 
    80   Raises:
    80   Raises:
    81     Error if path is "False" (None, empty string, etc.)
    81     Error if path is "False" (None, empty string, etc.)
    82   """
    82   """
    83 
    83 
    84   if not partial_path:
    84   if not scope_path:
    85     raise Error('"partial_path" must be non-False: "%s"' % partial_path)
    85     raise Error('"scope_path" must be non-False: "%s"' % scope_path)
    86 
    86 
    87   if not link_id:
    87   if not link_id:
    88     raise Error('"link_id" must be non-False: "%s"' % link_id)
    88     raise Error('"link_id" must be non-False: "%s"' % link_id)
    89 
    89 
    90   return 'HomeSettings:%s:%s' % (partial_path, link_id)
    90   return 'HomeSettings:%s:%s' % (scope_path, link_id)
    91 
    91 
    92 
    92 
    93 def nameUser(email):
    93 def nameUser(email):
    94   """Returns a User key name constructed from a supplied email address.
    94   """Returns a User key name constructed from a supplied email address.
    95   
    95