app/soc/logic/key_name.py
changeset 445 31927f21970d
parent 404 44223e50e1fc
child 499 d22e4fe8e64b
equal deleted inserted replaced
444:6e50bfc6e5a7 445:31927f21970d
    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(path):
    61 def nameSiteSettings(partial_path, link_name):
    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   if not path:
       
    68     raise Error('"path" must be non-False: "%s"' % path)
       
    69 
    67 
    70   return nameHomeSettings(path, entity_type='SiteSettings')
    68   if not partial_path:
       
    69     raise Error('"partial_path" must be non-False: "%s"' % partial_path)
       
    70 
       
    71   if not link_name:
       
    72     raise Error('"link_name" must be non-False: "%s"' % link_name)
       
    73 
       
    74   return 'SiteSettings:%s:%s' % (partial_path, link_name)
    71 
    75 
    72 
    76 
    73 def nameHomeSettings(path, entity_type='HomeSettings'):
    77 def nameHomeSettings(partial_path, link_name):
    74   """Returns a HomeSettings key name constructed from a supplied path.
    78   """Returns a HomeSettings key name constructed from a supplied path.
    75 
    79 
    76   Raises:
    80   Raises:
    77     Error if path is "False" (None, empty string, etc.)
    81     Error if path is "False" (None, empty string, etc.)
    78   """
    82   """
    79   if not path:
       
    80     raise Error('"path" must be non-False: "%s"' % path)
       
    81 
    83 
    82   return '%s:%s' % (entity_type, path)
    84   if not partial_path:
       
    85     raise Error('"partial_path" must be non-False: "%s"' % partial_path)
       
    86 
       
    87   if not link_name:
       
    88     raise Error('"link_name" must be non-False: "%s"' % link_name)
       
    89 
       
    90   return 'HomeSettings:%s:%s' % (partial_path, link_name)
    83 
    91 
    84 
    92 
    85 def nameUser(email):
    93 def nameUser(email):
    86   """Returns a User key name constructed from a supplied email address.
    94   """Returns a User key name constructed from a supplied email address.
    87   
    95