Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes
archetypes.kss.validation.ValidationView Class Reference
Inheritance diagram for archetypes.kss.validation.ValidationView:
Inheritance graph
[legend]
Collaboration diagram for archetypes.kss.validation.ValidationView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def kssValidateField
def kssValidateForm
def macroContent
def issueAllPortalMessages

Static Public Attributes

tuple header_macros = ZopeTwoPageTemplateFile('browser/macro_wrapper.pt')

Detailed Description

Definition at line 40 of file validation.py.


Member Function Documentation

Definition at line 45 of file plonekssview.py.

00045 
00046     def issueAllPortalMessages(self):
00047         if hasattr(self.request.RESPONSE, 'cookies'):
00048             cookie = self.request.RESPONSE.cookies.get(STATUSMESSAGEKEY)
00049             if cookie:
00050                 encodedstatusmessages = cookie['value']
00051                 statusmessages = _decodeCookieValue(encodedstatusmessages)
00052             else:
00053                 statusmessages = []
00054             for msg in statusmessages:
00055                 self.getCommandSet('plone').issuePortalMessage(msg)
00056             self.request.RESPONSE.expireCookie(STATUSMESSAGEKEY, path='/')

Here is the call graph for this function:

Here is the caller graph for this function:

def archetypes.kss.validation.ValidationView.kssValidateField (   self,
  fieldname,
  value,
  uid = None 
)
Validate a given field

Definition at line 48 of file validation.py.

00048 
00049     def kssValidateField(self, fieldname, value, uid=None):
00050         '''Validate a given field
00051         '''
00052         # validate the field, actually
00053 
00054         if uid is not None:
00055             rc = getToolByName(aq_inner(self.context), 'reference_catalog')
00056             instance = rc.lookupObject(uid)
00057         else:
00058             deprecated(ValidationView, missing_uid_deprecation)
00059             instance = aq_inner(self.context)
00060 
00061         field = instance.getField(fieldname)
00062         if field.type in SKIP_KSSVALIDATION_FIELDTYPES:
00063             return self.render()
00064         error = field.validate(value, instance, {})
00065         # XXX
00066         if isinstance(error, str):
00067             error = error.decode('utf', 'replace')
00068         # replace the error on the page
00069         self.getCommandSet('atvalidation').issueFieldError(fieldname, error)
00070         return self.render()

Definition at line 72 of file validation.py.

00072 
00073     def kssValidateForm(self, data):
00074         # Put the form vars on the request, as AT cannot work
00075         # from data
00076         self.request.form.update(data)
00077         # Check for Errors
00078         #errors = self.context.aq_inner.validate(self.request, errors={}, data=1, metadata=0)
00079         # this will skip some events but we don't care
00080         # the predicates should be passed from BaseObject.validate too
00081         instance = aq_inner(self.context)
00082         schema = instance.Schema()
00083         errors = validate(schema, instance, self.request, errors={}, data=1, metadata=0,
00084                 predicates=(lambda field: field.type not in SKIP_KSSVALIDATION_FIELDTYPES, ))
00085         ksscore = self.getCommandSet('core')
00086         if errors:
00087             # give the portal message
00088             self.getCommandSet('plone').issuePortalMessage(
00089                 _(u'Please correct the indicated errors.'))
00090             # reset all error fields (as we only know the error ones.)
00091             ksscore.clearChildNodes(ksscore.getCssSelector('div.field div.fieldErrorBox'))
00092             # Set error fields
00093             for fieldname, error in errors.iteritems():
00094                 # XXX
00095                 if isinstance(error, str):
00096                     error = error.decode('utf', 'replace')
00097                 self.getCommandSet('atvalidation').issueFieldError(fieldname, error)
00098         else:
00099             # I just resubmit the form then
00100             # XXX of course this should be handled from here, save the
00101             # content and redirect already to the result page - I guess
00102             # I just don't want to clean up AT form submit procedures
00103             self.commands.addCommand('plone-submitCurrentForm', ksscore.getSelector('samenode', ''))
00104         return self.render()
00105 
00106 
00107 # This is modified from Archetypes.Schema.validate

def plone.app.kss.plonekssview.PloneKSSView.macroContent (   self,
  macropath,
  kw 
) [inherited]

Definition at line 24 of file plonekssview.py.

00024 
00025     def macroContent(self, macropath, **kw):
00026         'Renders a macro and returns its text'
00027         path = macropath.split('/')
00028         if len(path) < 2 or path[-2] != 'macros':
00029             raise RuntimeError, 'Path must end with macros/name_of_macro (%s)' % (repr(macropath), )
00030         # needs string, do not tolerate unicode (causes but at traverse)
00031         jointpath = '/'.join(path[:-2]).encode('ascii')
00032         macroobj = self.context.restrictedTraverse(jointpath)
00033         try:
00034             the_macro = macroobj.macros[path[-1]]
00035         except AttributeError, IndexError:
00036             raise RuntimeError, 'Macro not found'
00037         #  
00038         # put parameters on the request, by saving the original context
00039         self.request.form, orig_form = kw, self.request.form
00040         content = self.header_macros.__of__(macroobj.aq_parent)(the_macro=the_macro)
00041         self.request.form = orig_form
00042         # Always encoded as utf-8
00043         content = force_unicode(content, 'utf')
00044         return content

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tuple plone.app.kss.plonekssview.PloneKSSView.header_macros = ZopeTwoPageTemplateFile('browser/macro_wrapper.pt') [static, inherited]

Definition at line 22 of file plonekssview.py.


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