Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFFormController.ControllerState.ControllerState Class Reference
Collaboration diagram for CMFFormController.ControllerState.ControllerState:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def set
def setError
def getError
def getI18NError
def getId
def setId
def getButton
def setButton
def getStatus
def setStatus
def getErrors
def getI18NErrors
def setErrors
def getContext
def setContext
def getKwargs
def setKwargs
def getNextAction
def setNextAction
def clearValidator
def clearValidators
def hasValidated
def __str__

Public Attributes

 status
 errors
 kwargs

Static Public Attributes

tuple security = ClassSecurityInfo()
 id = None
string status = 'success'
dictionary errors = {}
 context = None
 button = None
 next_action = None
dictionary kwargs = {}

Private Member Functions

def _addValidator
def _setValidating
def _isValidating

Private Attributes

 _is_validating
 _validators

Static Private Attributes

dictionary _validators = {}

Detailed Description

Definition at line 8 of file ControllerState.py.


Constructor & Destructor Documentation

def CMFFormController.ControllerState.ControllerState.__init__ (   self,
  id = None,
  context = None,
  button = None,
  status = 'success',
  errors = {},
  next_action = None,
  kwargs 
)

Definition at line 40 of file ControllerState.py.

00040 
00041                  errors={}, next_action=None, **kwargs):
00042         self.setId(id)
00043         self.setButton(button)
00044         self.setStatus(status)
00045         self.setErrors(errors)
00046         self.setContext(context)
00047         self.setKwargs(kwargs)
00048         self.setNextAction(next_action)
00049         self._is_validating = 0
00050         self._validators = {}
00051 

Here is the call graph for this function:


Member Function Documentation

Definition at line 242 of file ControllerState.py.

00242 
00243     def __str__(self):
00244         return 'id = %s\nstatus = %s\nbutton=%s\nerrors=%s\ncontext=%s\nkwargs=%s\nnext_action=%s\n' % \
00245             (self.id, str(self.getStatus()), str(self.getButton()),
00246              str(self.getErrors()), repr(self.getContext()),
00247              str(self.kwargs), str(self.next_action))
00248 
00249 Globals.InitializeClass(ControllerState)

Here is the call graph for this function:

def CMFFormController.ControllerState.ControllerState._addValidator (   self,
  validator 
) [private]

Definition at line 213 of file ControllerState.py.

00213 
00214     def _addValidator(self, validator):
00215         self._validators[validator] = 1

Definition at line 239 of file ControllerState.py.

00239 
00240     def _isValidating(self):
00241         return self._is_validating

def CMFFormController.ControllerState.ControllerState._setValidating (   self,
  is_validating 
) [private]

Definition at line 236 of file ControllerState.py.

00236 
00237     def _setValidating(self, is_validating):
00238         self._is_validating = is_validating

Definition at line 217 of file ControllerState.py.

00217 
00218     def clearValidator(self, validator):
00219         if self._validators.has_key(validator):
00220             del self._validators[validator]

Definition at line 222 of file ControllerState.py.

00222 
00223     def clearValidators(self):
00224         self._validators = {}

Get the name of the named button pressed.  You can name a button NAME
in a template by giving it the name form.button.NAME

Definition at line 103 of file ControllerState.py.

00103 
00104     def getButton(self):
00105         """Get the name of the named button pressed.  You can name a button NAME
00106         in a template by giving it the name form.button.NAME"""
00107         return self.button

Here is the caller graph for this function:

Get the context of the current form/script

Definition at line 154 of file ControllerState.py.

00154 
00155     def getContext(self):
00156         """Get the context of the current form/script"""
00157         if self.context is None:
00158             return self.context
00159         return self.context[0]
00160         #return aq_inner(self.context)

Here is the caller graph for this function:

Return the error message associated with the form variable id

Definition at line 83 of file ControllerState.py.

00083 
00084     def getError(self, id):
00085         """Return the error message associated with the form variable id"""
00086         err = self.errors.get(id, None)
00087         if err:
00088             return err[0]
00089         return None

Return all errors in a dict of the form dict['name'] = errmsg

Definition at line 121 of file ControllerState.py.

00121 
00122     def getErrors(self):
00123         """Return all errors in a dict of the form dict['name'] = errmsg"""
00124         err = {}
00125         for k,v in self.errors.items():
00126             # make allowances for old-style string errors
00127             if isinstance(v, basestring):
00128                 err[k] = v
00129             else:
00130                 err[k] = v[0]
00131         return err

Here is the caller graph for this function:

Return the error message and i18n msgid associated with the form
variable id.  The return value is the tuple (errmsg, i18n_msgid).

Definition at line 90 of file ControllerState.py.

00090 
00091     def getI18NError(self, id):
00092         """Return the error message and i18n msgid associated with the form
00093         variable id.  The return value is the tuple (errmsg, i18n_msgid)."""
00094         return self.errors.get(id, None)

Return all errors in a dict of the form dict['name'] = (errmsg, i18n_msgid)

Definition at line 132 of file ControllerState.py.

00132 
00133     def getI18NErrors(self):
00134         """Return all errors in a dict of the form dict['name'] = (errmsg, i18n_msgid)"""
00135         err = {}
00136         for k,v in self.errors.items():
00137             # make allowances for old-style string errors
00138             if isinstance(v, basestring):
00139                 err[k] = (v, None)
00140             else:
00141                 err[k] = v
00142         return err

Get the id of the calling script/page template

Definition at line 95 of file ControllerState.py.

00095 
00096     def getId(self):
00097         """Get the id of the calling script/page template"""
00098         return self.id

Get any extra arguments that should be passed along to the
next template/script

Definition at line 169 of file ControllerState.py.

00169 
00170     def getKwargs(self):
00171         """Get any extra arguments that should be passed along to the
00172         next template/script"""
00173         return self.kwargs

Get the default next action (this action can be overridden in
portal_form_controller).  The action will have the form
{'action_type':action_type, 'args':args} where action_type is a string
(from portal_form_controller.validActionTypes), and args is a string
that will be passed to the constructor when generating an action object

Definition at line 179 of file ControllerState.py.

00179 
00180     def getNextAction(self):
00181         """Get the default next action (this action can be overridden in
00182         portal_form_controller).  The action will have the form
00183         {'action_type':action_type, 'args':args} where action_type is a string
00184         (from portal_form_controller.validActionTypes), and args is a string
00185         that will be passed to the constructor when generating an action object"""
00186         return self.next_action

Get the current status

Definition at line 113 of file ControllerState.py.

00113 
00114     def getStatus(self):
00115         """Get the current status"""
00116         return self.status

Here is the caller graph for this function:

Definition at line 226 of file ControllerState.py.

00226 
00227     def hasValidated(self, validators=[]):
00228         if validators is None:
00229             validators = []
00230         elif not isinstance(validators, list):
00231             validators = [validators]
00232         for v in validators:
00233             if not self._validators.has_key(v):
00234                 return 0
00235         return 1

Set state object properties

Definition at line 52 of file ControllerState.py.

00052 
00053     def set(self, **kwargs):
00054         """Set state object properties"""
00055         if kwargs.has_key('id'):
00056             self.setId(kwargs['id'])
00057             del kwargs['id']
00058         if kwargs.has_key('button'):
00059             self.setButton(kwargs['button'])
00060             del kwargs['button']
00061         if kwargs.has_key('status'):
00062             self.setStatus(kwargs['status'])
00063             del kwargs['status']
00064         if kwargs.has_key('errors'):
00065             self.setErrors(kwargs['errors'])
00066             del kwargs['errors']
00067         if kwargs.has_key('context'):
00068             self.setContext(kwargs['context'])
00069             del kwargs['context']
00070         if kwargs.has_key('next_action'):
00071             self.setNextAction(kwargs['next_action'])
00072             del kwargs['next_action']
00073         self.kwargs.update(kwargs)
00074         return self
00075 

Here is the call graph for this function:

Here is the caller graph for this function:

Set the name of the named button pressed.  You can name a button NAME
in a template by giving it the name form.button.NAME

Definition at line 108 of file ControllerState.py.

00108 
00109     def setButton(self, button):
00110         """Set the name of the named button pressed.  You can name a button NAME
00111         in a template by giving it the name form.button.NAME"""
00112         self.button = button

Here is the caller graph for this function:

Set the context of the current form/script

Definition at line 161 of file ControllerState.py.

00161 
00162     def setContext(self, context):
00163         """Set the context of the current form/script"""
00164         # Store the context in a list so that we don't nuke its acquisition chain.
00165         # This is kind of an evil hack, but since we aren't persisting
00166         # ControllerState objects, it shouldn't cause any big problems.
00167         self.context = [context]
00168         # self.context = context

Here is the caller graph for this function:

def CMFFormController.ControllerState.ControllerState.setError (   self,
  id,
  message,
  msgid = None,
  new_status = None 
)
Add an error message to the current state object.  The new_status
argument allows you to optionally change the object's status.

Definition at line 76 of file ControllerState.py.

00076 
00077     def setError(self, id, message, msgid=None, new_status=None):
00078         """Add an error message to the current state object.  The new_status
00079         argument allows you to optionally change the object's status."""
00080         self.errors[id] = (message, msgid)
00081         if new_status:
00082             self.status = new_status

Set the error dictionary.  The dictionary should have entries of the
form dict['name'] = (errmsg, i18n_msgid).  The msgid can be None

Definition at line 143 of file ControllerState.py.

00143 
00144     def setErrors(self, errors):
00145         """Set the error dictionary.  The dictionary should have entries of the
00146         form dict['name'] = (errmsg, i18n_msgid).  The msgid can be None"""
00147         self.errors = {}
00148         # make allowances for old-style errors
00149         for k,v in errors.items():
00150             if isinstance(v, basestring):
00151                 self.errors[k] = (v, None)
00152             else:
00153                 self.errors[k] = v

Here is the caller graph for this function:

Set the id of the calling script/page template

Definition at line 99 of file ControllerState.py.

00099 
00100     def setId(self, id):
00101         """Set the id of the calling script/page template"""
00102         self.id = id

Here is the caller graph for this function:

Set any extra arguments that should be passed along to the
next template/script

Definition at line 174 of file ControllerState.py.

00174 
00175     def setKwargs(self, kwargs):
00176         """Set any extra arguments that should be passed along to the
00177         next template/script"""
00178         self.kwargs = kwargs

Here is the caller graph for this function:

Set the default next action (this action can be overridden in
portal_form_controller).  setNextAction can be called either with a
dictionary argument of the form {'action_type':action_type, 'args':args}
or with a string of the form 'action_type:args'.  Here action_type is a
string (from form_controller.validActionTypes) and args is a string that
will be passed to the constructor when generating an action object

Definition at line 187 of file ControllerState.py.

00187 
00188     def setNextAction(self, action):
00189         """Set the default next action (this action can be overridden in
00190         portal_form_controller).  setNextAction can be called either with a
00191         dictionary argument of the form {'action_type':action_type, 'args':args}
00192         or with a string of the form 'action_type:args'.  Here action_type is a
00193         string (from form_controller.validActionTypes) and args is a string that
00194         will be passed to the constructor when generating an action object"""
00195         if action is None:
00196             self.next_action = action
00197             return
00198         if isinstance(action, dict):
00199             action_type = action['action_type']
00200             args = action['args']
00201         else:
00202             split_action = action.split(':',1)
00203             action_type = split_action[0].strip()
00204             if len(split_action) == 2:
00205                 args = split_action[1].strip()
00206             else:
00207                 args = None
00208         controller = getToolByName(self.getContext(), 'portal_form_controller')
00209         if not action_type in controller.validActionTypes():
00210             raise KeyError, 'Unknown action type %s\n' % action_type
00211         self.next_action = FormAction(self.getId(), self.getStatus(), ANY_CONTEXT, ANY_BUTTON, action_type, args, controller)

Here is the call graph for this function:

Here is the caller graph for this function:

Get the current status

Definition at line 117 of file ControllerState.py.

00117 
00118     def setStatus(self, status):
00119         """Get the current status"""
00120         self.status = status

Here is the caller graph for this function:


Member Data Documentation

Definition at line 48 of file ControllerState.py.

Definition at line 37 of file ControllerState.py.

Definition at line 49 of file ControllerState.py.

Definition at line 27 of file ControllerState.py.

Definition at line 24 of file ControllerState.py.

Definition at line 21 of file ControllerState.py.

Definition at line 146 of file ControllerState.py.

Definition at line 13 of file ControllerState.py.

Definition at line 34 of file ControllerState.py.

Definition at line 177 of file ControllerState.py.

Definition at line 31 of file ControllerState.py.

tuple CMFFormController.ControllerState.ControllerState.security = ClassSecurityInfo() [static]

Definition at line 9 of file ControllerState.py.

Definition at line 16 of file ControllerState.py.

Definition at line 81 of file ControllerState.py.


The documentation for this class was generated from the following file: