Back to index

plone3  3.1.7
validation.py
Go to the documentation of this file.
00001 from Acquisition import aq_inner
00002 
00003 from kss.core.kssview import CommandSet
00004 
00005 
00006 class ValidationCommands(CommandSet):
00007 
00008     __allow_access_to_unprotected_subobjects__ = 1
00009 
00010     def issueFieldError(self, fieldname, error):
00011         'Issue this error message for the field'
00012         context = aq_inner(self.context)
00013         ksscore = self.getCommandSet('core')
00014         selector = ksscore.getCssSelector('div#archetypes-fieldname-%s div.fieldErrorBox' % fieldname)
00015         if error:
00016             ksscore.replaceInnerHTML(selector, error)
00017             errorklass = ' error'
00018         else:
00019             ksscore.clearChildNodes(selector)
00020             errorklass = ''
00021         klass = "field%s Archetypes%sfield" % (errorklass, fieldname)
00022         kssattr = context.restrictedTraverse('kss_field_decorator_view').getKssClasses(fieldname)
00023         if kssattr:
00024             klass += ' ' + kssattr
00025         # set the field style in the required way
00026         ksscore.setAttribute(
00027             ksscore.getHtmlIdSelector('archetypes-fieldname-%s' % fieldname),
00028             'class', klass)