--- a/app/soc/logic/models/base.py Sat Dec 06 11:21:41 2008 +0000
+++ b/app/soc/logic/models/base.py Sat Dec 06 11:26:15 2008 +0000
@@ -77,6 +77,15 @@
return self._scope_logic
+ def getScopeDepth(self):
+ """
+ """
+
+ if self._scope_logic:
+ return 1 + self._scope_logic.logic.getScopeDepth()
+
+ return 0
+
def _updateField(self, model, name, value):
"""Hook called when a field is updated.
@@ -226,13 +235,12 @@
key_name = self.getKeyNameForFields(kwargs)
if key_name:
- entity = self._model.get_by_key_name(key_name)
+ entity = self.getFromKeyName(key_name)
else:
entity = None
return entity
-
def getFromFieldsOr404(self, **fields):
"""Like getFromFields but expects to find an entity.
@@ -258,7 +266,6 @@
raise out_of_band.Error(msg, status=404)
-
def getIfFields(self, fields):
"""Like getFromFieldsOr404 but returns None if not all fields are set
@@ -271,7 +278,6 @@
return self.getFromFieldsOr404(**fields)
-
def getKeyNameForFields(self, fields):
"""Return a Datastore key_name for a Entity from the specified fields.
--- a/app/soc/views/helper/params.py Sat Dec 06 11:21:41 2008 +0000
+++ b/app/soc/views/helper/params.py Sat Dec 06 11:26:15 2008 +0000
@@ -241,11 +241,16 @@
first part of the returned pattern.
"""
- names = params['logic'].getKeyFieldNames()
+ logic = params['logic']
+ names = logic.getKeyFieldNames()
patterns = params['key_fields_prefix']
for name in names:
- pattern = r'(?P<%s>%s)' % (name, linkable.LINK_ID_PATTERN_CORE)
+ regexp = linkable.LINK_ID_PATTERN_CORE
+ if name == 'scope_path':
+ regexp = '/'.join((regexp for i in range(logic.getScopeDepth())))
+
+ pattern = r'(?P<%s>%s)' % (name, regexp)
patterns.append(pattern)
result = '/'.join(patterns)