web/views/urlrewrite.py
branchstable
changeset 3865 f9778a00e47f
parent 3864 2fee9151c6b2
child 3890 d7a270f50f54
child 4212 ab6573088b4a
equal deleted inserted replaced
3864:2fee9151c6b2 3865:f9778a00e47f
   147         return None, None
   147         return None, None
   148     return do_build_rset
   148     return do_build_rset
   149 
   149 
   150 def rgx_action(rql=None, args=None, cachekey=None, argsgroups=(), setuser=False,
   150 def rgx_action(rql=None, args=None, cachekey=None, argsgroups=(), setuser=False,
   151                form=None, formgroups=(), transforms={}, controller=None):
   151                form=None, formgroups=(), transforms={}, controller=None):
   152     def do_build_rset(inputurl, uri, req, schema):
   152     def do_build_rset(inputurl, uri, req, schema,
       
   153                       cachekey=cachekey # necessary to avoid UnboundLocalError
       
   154                       ):
   153         if rql:
   155         if rql:
   154             kwargs = args and args.copy() or {}
   156             kwargs = args and args.copy() or {}
   155             cachekey = cachekey # necessary to avoid UnboundLocalError
       
   156             if argsgroups:
   157             if argsgroups:
   157                 if cachekey is not None and isinstance(cachekey, basestring):
   158                 if cachekey is not None and isinstance(cachekey, basestring):
   158                     cachekey = (cachekey,)
   159                     cachekey = (cachekey,)
   159                 match = inputurl.match(uri)
   160                 match = inputurl.match(uri)
   160                 for key in argsgroups:
   161                 for key in argsgroups:
   161                     value = match.group(key)
   162                     value = match.group(key)
   162                     try:
   163                     try:
   163                         kwargs[key] = transforms[key](value)
   164                         kwargs[key] = transforms[key](value)
   164                     except KeyError:
   165                     except KeyError:
   165                         kwargs[key] = value
   166                         kwargs[key] = value
   166                     if key in cachekey:
   167                     if cachekey is not None and key in cachekey:
   167                         kwargs[key] = typed_eid(value)
   168                         kwargs[key] = typed_eid(value)
   168             if setuser:
   169             if setuser:
   169                 kwargs['u'] = req.user.eid
   170                 kwargs['u'] = req.user.eid
   170             rset = req.execute(rql, kwargs, cachekey)
   171             rset = req.execute(rql, kwargs, cachekey)
   171         else:
   172         else: