Ejemplo n.º 1
0
    def _read_validator_metadata(self, id, filepath):
        self.validators = FormValidatorContainer()

        metadata = FSMetadata(filepath)
        cfg = CMFConfigParser()
        if os.path.exists(filepath + '.metadata'):
            cfg.read(filepath + '.metadata')
            _buttons_for_status = {}

            validators = metadata._getSectionDict(cfg, 'validators')
            if validators is None:
                validators = {}
            for (k, v) in validators.items():
                # validators.CONTEXT_TYPE.BUTTON = LIST
                component = k.split('.')
                while len(component) < 3:
                    component.append('')
                if component[0] != 'validators':
                    raise ValueError, '%s: Format for .metadata validators is validators.CONTEXT_TYPE.BUTTON = LIST (not %s)' % (
                        filepath, k)

                context_type = component[1]
                self.validators.set(
                    FormValidator(id, component[1], component[2], v))

                status_key = str(context_type)
                if _buttons_for_status.has_key(status_key):
                    _buttons_for_status[status_key].append(component[2])
                else:
                    _buttons_for_status[status_key] = [component[2]]

            for (k, v) in _buttons_for_status.items():
                if v and not '' in v:
                    content_type = k
                    if not content_type:
                        content_type = 'ANY'
                    log('%s: No default validators specified for content type %s.  Users of IE can submit pages using the return key, resulting in no button in the REQUEST.  Please specify default validators for this case.'
                        % (str(filepath), content_type),
                        log_level=logging.DEBUG)
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     self.validators = FormValidatorContainer()
     self.actions = FormActionContainer()
     return ControllerPythonScript.inheritedAttribute('__init__')(self,
                                                                  *args,
                                                                  **kwargs)
Ejemplo n.º 3
0
 def __init__(self):
     self.actions = FormActionContainer()
     self.validators = FormValidatorContainer()