Back to index

plone3  3.1.7
BaseControllerPageTemplate.py
Go to the documentation of this file.
00001 import Globals
00002 from AccessControl import ClassSecurityInfo
00003 from Products.CMFCore.permissions import View
00004 from Products.CMFCore.utils import getToolByName
00005 from ControllerBase import ControllerBase
00006 
00007 class BaseControllerPageTemplate(ControllerBase):
00008 
00009     security = ClassSecurityInfo()
00010     security.declareObjectProtected(View)
00011 
00012     def _call(self, inherited_call, *args, **kwargs):
00013         # Intercept a call to a form and see if REQUEST.form contains the
00014         # value form.submitted.  If so, perform validation.  If not, update
00015         # the controller state and treat as a normal form.
00016 
00017         REQUEST = self.REQUEST
00018 
00019         controller = getToolByName(self, 'portal_form_controller')
00020         controller_state = controller.getState(self, is_validator=0)
00021 
00022         form_submitted = REQUEST.form.get('form.submitted', None)
00023         if form_submitted:
00024             controller_state = self.getButton(controller_state, REQUEST)
00025             validators = self.getValidators(controller_state, REQUEST).getValidators()
00026             controller_state = controller.validate(controller_state, REQUEST, validators)
00027             del REQUEST.form['form.submitted']
00028             return self.getNext(controller_state, REQUEST)
00029 
00030         kwargs['state'] = controller_state
00031         return inherited_call(self, *args, **kwargs)
00032 
00033 
00034 Globals.InitializeClass(BaseControllerPageTemplate)