[gen] Added method Mixin.onCall allowing to call a specific method on a gen-class from the UI.

This commit is contained in:
Gaetan Delannay 2014-04-25 12:14:50 +02:00
parent ef21375410
commit cee7b49e3c
2 changed files with 22 additions and 11 deletions

View file

@ -1180,7 +1180,7 @@ class BaseMixin:
rq = self.getProductConfig().fakeRequest
if not hasattr(rq, 'wrappers'): rq.wrappers = {}
# Return the Appy wrapper if already present in the cache
uid = self.UID()
uid = self.id
if uid in rq.wrappers: return rq.wrappers[uid]
# Create the Appy wrapper, cache it in rq.wrappers and return it
wrapper = self.wrapperClass(self)
@ -1559,4 +1559,11 @@ class BaseMixin:
'''This method is a general hook for transfering processing of a request
to a given field, whose name must be in the request.'''
return self.getAppyType(self.REQUEST['name']).process(self)
def onCall(self):
'''Calls a specific method on the corresponding wrapper.'''
self.allows('read', raiseError=True)
method = self.REQUEST['method']
obj = self.appy()
return getattr(obj, method)()
# ------------------------------------------------------------------------------