[gen] Modified Ajax system to be able to ajax-refresh a single row within query results or ref tied object (ongoing work).

This commit is contained in:
Gaetan Delannay 2015-02-03 10:56:15 +01:00
parent f047242d81
commit 1bd6cf29a3
11 changed files with 417 additions and 302 deletions

View file

@ -272,12 +272,6 @@ class ToolMixin(BaseMixin):
for key in self.queryParamNames])
return res
def getResultMode(self, className):
'''Must we show, on pxQueryResult, instances of p_className as a list or
as a grid?'''
klass = self.getAppyClass(className)
return getattr(klass, 'resultMode', 'list')
def showPortlet(self, obj, layoutType):
'''When must the portlet be shown? p_obj and p_layoutType can be None
if we are not browing any objet (ie, we are on the home page).'''
@ -1298,4 +1292,18 @@ class ToolMixin(BaseMixin):
if field: msg = getattr(field, action)(obj.o)
else: msg = getattr(obj.o, action)()
return msg
def updatePxContextFromRequest(self):
'''Takes any user-defined key from the request and put it as a variable
on the current PX context.'''
req = self.REQUEST
ctx = req.pxContext
# Get "form" data (get, post) and cookie values
for source in (req.form, req.cookies):
for k, v in source.iteritems():
# Convert v to some Python data when relevant
if v in ('True', 'False', 'true', 'false'):
exec 'v = %s' % v.capitalize()
elif v.isdigit(): v = int(v)
ctx[k] = v
# ------------------------------------------------------------------------------

View file

@ -1019,9 +1019,9 @@ class BaseMixin:
wf = self.getWorkflow()
# Get the initial workflow state
initialState = self.State(name=False)
# Create a Transition instance representing the initial transition.
# Create a Transition instance representing the initial transition
initialTransition = gen.Transition((initialState, initialState))
initialTransition.trigger('_init_', self, wf, '')
initialTransition.trigger('_init_', self, wf, '', doSay=False)
def getWorkflow(self, name=False, className=None):
'''Returns the workflow applicable for p_self (or for any instance of