5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 import re |
8 import re |
9 |
9 |
|
10 from cubicweb import typed_eid |
10 from cubicweb.appobject import AppObject |
11 from cubicweb.appobject import AppObject |
11 |
12 |
12 |
13 |
13 def rgx(pattern, flags=0): |
14 def rgx(pattern, flags=0): |
14 """this is just a convenient shortcout to add the $ sign""" |
15 """this is just a convenient shortcout to add the $ sign""" |
150 form=None, formgroups=(), transforms={}, controller=None): |
151 form=None, formgroups=(), transforms={}, controller=None): |
151 def do_build_rset(inputurl, uri, req, schema): |
152 def do_build_rset(inputurl, uri, req, schema): |
152 if rql: |
153 if rql: |
153 kwargs = args and args.copy() or {} |
154 kwargs = args and args.copy() or {} |
154 if argsgroups: |
155 if argsgroups: |
|
156 if cachekey is not None and isinstance(cachekey, basestring): |
|
157 cachekey = (cachekey,) |
155 match = inputurl.match(uri) |
158 match = inputurl.match(uri) |
156 for key in argsgroups: |
159 for key in argsgroups: |
157 value = match.group(key) |
160 value = match.group(key) |
158 try: |
161 try: |
159 kwargs[key] = transforms[key](value) |
162 kwargs[key] = transforms[key](value) |
160 except KeyError: |
163 except KeyError: |
161 kwargs[key] = value |
164 kwargs[key] = value |
|
165 if key in cachekey: |
|
166 kwargs[key] = typed_eid(value) |
162 if setuser: |
167 if setuser: |
163 kwargs['u'] = req.user.eid |
168 kwargs['u'] = req.user.eid |
164 rset = req.execute(rql, kwargs, cachekey) |
169 rset = req.execute(rql, kwargs, cachekey) |
165 else: |
170 else: |
166 rset = None |
171 rset = None |