app/soc/logic/models/base.py
changeset 403 d3e545a8bd26
parent 402 021e86368600
child 407 3cf5630d86d1
equal deleted inserted replaced
402:021e86368600 403:d3e545a8bd26
   125     if not all(kwargs.values()):
   125     if not all(kwargs.values()):
   126       return None
   126       return None
   127 
   127 
   128     return self._keyName(**kwargs)
   128     return self._keyName(**kwargs)
   129 
   129 
   130   def constructKeyNameSuffix(self, fields):
   130   def getEmptyKeyFields(self):
       
   131     """Returns an dict with all the entities key_fields set to None
       
   132     """
       
   133 
       
   134     kwargs = {}
       
   135 
       
   136     for field in self._model.KEY_FIELDS:
       
   137       kwargs[field] = None
       
   138 
       
   139     return kwargs
       
   140 
       
   141   def constructKeyNameSuffix(self, entity):
   131     """Constructs a suffix from the specified fields
   142     """Constructs a suffix from the specified fields
   132 
   143 
   133     The resulting suffix is constructed by adding a '/' after all
   144     The resulting suffix is constructed by adding a '/' after all
   134     key fields. The suffix is constructed in the order as specified
   145     key fields. The suffix is constructed in the order as specified
   135     in the model's key_fields property. The suffix will not have a
   146     in the model's key_fields property. The suffix will not have a
   140           of this entity.
   151           of this entity.
   141     """
   152     """
   142 
   153 
   143     suffix = []
   154     suffix = []
   144 
   155 
   145     for field in self._model.KEY_FIELDS:
   156     for field in entity.KEY_FIELDS:
   146       suffix.append(fields[field])
   157       # Four hours wasted on this line, because apparently passing in a dict
   147 
   158       # one time, and a db.Model the next time, things get rather hard to debug
   148     return '/'.join(suffix)
   159       value = entity.__getattribute__(field)
   149 
   160       suffix.append(value)
   150   def getEmptyKeyFields(self):
   161 
   151     """Returns an dict with all the entities key_fields set to None
   162     res = '/'.join(suffix)
   152     """
   163     return res
   153 
       
   154     kwargs = {}
       
   155 
       
   156     for field in self._model.KEY_FIELDS:
       
   157       kwargs[field] = None
       
   158 
       
   159     return kwargs
       
   160 
   164 
   161   def extractKeyFields(self, fields):
   165   def extractKeyFields(self, fields):
   162     """Extracts all the fields from that are in the mode's key_fields property
   166     """Extracts all the fields from that are in the mode's key_fields property
   163 
   167 
   164     Args:
   168     Args: