app/soc/logic/models/base.py
changeset 399 b82852e6963e
parent 396 6af084bd290c
child 402 021e86368600
equal deleted inserted replaced
398:aa1e786a0b1d 399:b82852e6963e
   121     if not all(kwargs.values()):
   121     if not all(kwargs.values()):
   122       return None
   122       return None
   123 
   123 
   124     return self._keyName(**kwargs)
   124     return self._keyName(**kwargs)
   125 
   125 
       
   126   def constructKeyNameSuffix(self, fields):
       
   127     """Constructs a suffix from the specified fields
       
   128 
       
   129     The resulting suffix is constructed by adding a '/' after all
       
   130     key fields. The suffix is constructed in the order as specified
       
   131     in the model's key_fields property. The suffix will not have a
       
   132     trailing '/'.
       
   133 
       
   134     Args:
       
   135       fields: a dictionary with the values for all the key_fields
       
   136           of this entity.
       
   137     """
       
   138 
       
   139     suffix = ''
       
   140 
       
   141     for field in self._model.key_fields:
       
   142       suffix += fields[field]
       
   143       suffix += '/'
       
   144 
       
   145     if suffix.endswith('/'):
       
   146       suffix = suffix[:-1]
       
   147 
       
   148     return suffix
       
   149 
       
   150   def getEmptyKeyFields(self):
       
   151     """Returns an dict with all the entities key_fields set to None
       
   152     """
       
   153 
       
   154     kwargs = {}
       
   155 
       
   156     for field in self._model.key_fields:
       
   157       kwargs[field] = None
       
   158 
       
   159     return kwargs
       
   160 
   126   def extractKeyFields(self, fields):
   161   def extractKeyFields(self, fields):
   127     """Extracts all the fields from that are in the mode's key_fields property
   162     """Extracts all the fields from that are in the mode's key_fields property
   128 
   163 
   129     Args:
   164     Args:
   130       fields: A dict from which the fields should be extracted
   165       fields: A dict from which the fields should be extracted