# HG changeset patch # User Sverre Rabbelier # Date 1233352849 0 # Node ID e143974a6e27dcd2eda79ec249456ccd19e405eb # Parent 05ac761edb275f2e2e02daeacb9edfe530d5dd4d Factor out the getPattern logic from params This is to facilitate it's use by the document view later on. Patch by: Sverre Rabbelier diff -r 05ac761edb27 -r e143974a6e27 app/soc/views/helper/params.py --- a/app/soc/views/helper/params.py Fri Jan 30 22:00:23 2009 +0000 +++ b/app/soc/views/helper/params.py Fri Jan 30 22:00:49 2009 +0000 @@ -269,11 +269,24 @@ """ names = params['logic'].getKeyFieldNames() + scope_path_pattern = params['scope_path_pattern'] + + return getPattern(names, scope_path_pattern) + + +def getPattern(names, scope_path_pattern): + """Returns the Django patterns for the specified names. + + Args: + names: the field names that should be included in the pattern + scope_path_pattern: the pattern to use if the name is 'scope_path' + """ + patterns = [] for name in names: if name == 'scope_path': - pattern = params['scope_path_pattern'] + pattern = scope_path_pattern else: pattern = r'(?P<%s>%s)' % (name, linkable.LINK_ID_PATTERN_CORE) patterns.append(pattern)