equal
deleted
inserted
replaced
54 self._base_model = base_model |
54 self._base_model = base_model |
55 |
55 |
56 if name: |
56 if name: |
57 self._name = name |
57 self._name = name |
58 else: |
58 else: |
59 self._name = self.getModelClassName() |
59 self._name = self._model.__name__ |
60 |
60 |
61 if skip_properties: |
61 if skip_properties: |
62 self._skip_properties = skip_properties |
62 self._skip_properties = skip_properties |
63 else: |
63 else: |
64 self._skip_properties = [] |
64 self._skip_properties = [] |
99 keyvalues = [] |
99 keyvalues = [] |
100 for key_field_name in key_field_names: |
100 for key_field_name in key_field_names: |
101 keyvalues.append(kwargs[key_field_name]) |
101 keyvalues.append(kwargs[key_field_name]) |
102 |
102 |
103 # construct the KeyName in the appropriate format |
103 # construct the KeyName in the appropriate format |
104 return ":".join([self._name] + keyvalues) |
104 return "%s:%s" % (self._name, '/'.join(keyvalues)) |
105 |
|
106 def getModelClassName(self): |
|
107 """Returns model class name string. |
|
108 """ |
|
109 return self._model.__name__ |
|
110 |
105 |
111 def getFullModelClassName(self): |
106 def getFullModelClassName(self): |
112 """Returns fully-qualified model module.class name string. |
107 """Returns fully-qualified model module.class name string. |
113 """ |
108 """ |
114 return '%s.%s' % (self._model.__module__, |
109 return '%s.%s' % (self._model.__module__, self._model.__name__) |
115 self.getModelClassName()) |
|
116 |
110 |
117 def getKeyValues(self, entity): |
111 def getKeyValues(self, entity): |
118 """Exctracts the key values from entity and returns them. |
112 """Exctracts the key values from entity and returns them. |
119 |
113 |
120 Args: |
114 Args: |
472 the entity corresponding to the key_name, with any supplied |
466 the entity corresponding to the key_name, with any supplied |
473 properties changed, or a new entity now associated with the |
467 properties changed, or a new entity now associated with the |
474 supplied key_name and properties. |
468 supplied key_name and properties. |
475 """ |
469 """ |
476 |
470 |
|
471 import logging |
|
472 logging.info(key_name) |
|
473 logging.info(properties) |
|
474 |
477 entity = self.getFromKeyName(key_name) |
475 entity = self.getFromKeyName(key_name) |
478 |
476 |
479 if not entity: |
477 if not entity: |
480 # entity did not exist, so create one in a transaction |
478 # entity did not exist, so create one in a transaction |
481 entity = self._model.get_or_insert(key_name, **properties) |
479 entity = self._model.get_or_insert(key_name, **properties) |