_logger = logging.getLogger(__name__)
-
-# FIXME: replace by proxy on request.uid?
-_uid = object()
+UID_PLACEHOLDER = object()
class ModelConverter(werkzeug.routing.BaseConverter):
def to_python(self, value):
m = re.match(self.regex, value)
return request.registry[self.model].browse(
- request.cr, _uid, int(m.group(1)), context=request.context)
+ request.cr, UID_PLACEHOLDER, int(m.group(1)), context=request.context)
def to_url(self, value):
return value.id
# TODO:
# - raise routing.ValidationError() if no browse record can be createdm
# - support slug
- return request.registry[self.model].browse(request.cr, _uid, [int(i) for i in value.split(',')], context=request.context)
+ return request.registry[self.model].browse(request.cr, UID_PLACEHOLDER, [int(i) for i in value.split(',')], context=request.context)
def to_url(self, value):
return ",".join(i.id for i in value)
# post process arg to set uid on browse records
for arg in arguments.itervalues():
- if isinstance(arg, orm.browse_record) and arg._uid is _uid:
+ if isinstance(arg, orm.browse_record) and arg._uid is UID_PLACEHOLDER:
arg._uid = request.uid
+ try:
+ arg[arg._rec_name]
+ except KeyError:
+ return self._handle_exception(werkzeug.exceptions.NotFound())
# set and execute handler
try: