app/soc/views/helper/params.py
changeset 679 77a286ff6667
parent 673 2433d5c1d7e6
child 680 7f047b2a2d3a
equal deleted inserted replaced
678:b982d9175605 679:77a286ff6667
   243 
   243 
   244   names = params['logic'].getKeyFieldNames()
   244   names = params['logic'].getKeyFieldNames()
   245   patterns = params['key_fields_prefix']
   245   patterns = params['key_fields_prefix']
   246 
   246 
   247   for name in names:
   247   for name in names:
   248     pattern = r'(?P<%s>%s)' % (name, linkable.LINK_ID_PATTERN_CORE)
   248     if name == 'scope_path':
       
   249       pattern = getScopePattern(params)
       
   250     else:
       
   251       pattern = r'(?P<%s>%s)' % (name, linkable.LINK_ID_PATTERN_CORE)
   249     patterns.append(pattern)
   252     patterns.append(pattern)
   250 
   253 
   251   result = '/'.join(patterns)
   254   result = '/'.join(patterns)
   252   return result
   255   return result
       
   256 
       
   257 def getScopePattern(params):
       
   258   """Returns the Scope pattern for this entity
       
   259   """
       
   260 
       
   261   logic = params['logic']
       
   262   depth = logic.getScopeDepth()
       
   263   if depth is None:
       
   264     return linkable.SCOPE_PATH_ARG_PATTERN
       
   265 
       
   266   regexps = [linkable.LINK_ID_PATTERN_CORE for i in range(depth)]
       
   267   regexp = '/'.join(regexps)
       
   268   return r'(?P<scope_path>%s)' % regexp