Ejemplo n.º 1
0
 def testImplementIMultiPageSchema(self):
     try:
         from Products.Archetypes.interfaces import IMultiPageSchema
         self.ff1.invokeFactory('SalesforcePFGAdapter', 'salesforce')
         sf = self.ff1.salesforce
         self.assertTrue(IMultiPageSchema.providedBy(sf))
     except ImportError:
         pass
Ejemplo n.º 2
0
 def testImplementIMultiPageSchema(self):
     try:
         from Products.Archetypes.interfaces import IMultiPageSchema
         self.ff1.invokeFactory('SalesforcePFGAdapter', 'salesforce')
         sf = self.ff1.salesforce
         self.assertTrue(IMultiPageSchema.providedBy(sf))
     except ImportError:
         pass
Ejemplo n.º 3
0
    def _processForm(self, data=1, metadata=None, REQUEST=None, values=None):
        request = REQUEST or self.REQUEST
        if values:
            form = values
        else:
            form = request.form
        fieldset = form.get('fieldset', None)
        schema = self.Schema()
        schemata = self.Schemata()
        fields = []

        if not IMultiPageSchema.providedBy(self):
            fields = schema.fields()
        elif fieldset is not None:
            fields = schemata[fieldset].fields()
        else:
            if data: fields += schema.filterFields(isMetadata=0)
            if metadata: fields += schema.filterFields(isMetadata=1)

        form_keys = form.keys()

        for field in fields:
            ## Delegate to the widget for processing of the form
            ## element.  This means that if the widget needs _n_
            ## fields under a naming convention it can handle this
            ## internally.  The calling API is process_form(instance,
            ## field, form) where instance should rarely be needed,
            ## field is the field object and form is the dict. of
            ## kv_pairs from the REQUEST
            ##
            ## The product of the widgets processing should be:
            ##   (value, **kwargs) which will be passed to the mutator
            ##   or None which will simply pass

            if not field.writeable(self):
                # If the field has no 'w' in mode, or the user doesn't
                # have the required permission, or the mutator doesn't
                # exist just bail out.
                continue

            try:
                # Pass validating=False to inform the widget that we
                # aren't in the validation phase, IOW, the returned
                # data will be forwarded to the storage
                result = field.widget.process_form(self, field, form,
                                                   empty_marker=_marker,
                                                   validating=False)
            except TypeError:
                # Support for old-style process_form methods
                result = field.widget.process_form(self, field, form,
                                                   empty_marker=_marker)

            if result is _marker or result is None:
                continue

            # Set things by calling the mutator
            mutator = field.getMutator(self)
            __traceback_info__ = (self, field, mutator)
            result[1]['field'] = field.__name__
            mapply(mutator, result[0], **result[1])

        self.reindexObject()
Ejemplo n.º 4
0
def patched_processForm(self,
                        data=1,
                        metadata=None,
                        REQUEST=None,
                        values=None):
    request = REQUEST or self.REQUEST
    if values:
        form = values
    else:
        form = request.form
    fieldset = form.get('fieldset', None)
    schema = self.Schema()
    schemata = self.Schemata()
    fields = []

    if MULTI_PAGE and not IMultiPageSchema.providedBy(self):
        fields = schema.fields()
    elif fieldset is not None:
        fields = schemata[fieldset].fields()
    else:
        if data:
            fields += schema.filterFields(isMetadata=0)
        if metadata:
            fields += schema.filterFields(isMetadata=1)

    form_keys = form.keys()

    for field in fields:
        ## Delegate to the widget for processing of the form
        ## element.  This means that if the widget needs _n_
        ## fields under a naming convention it can handle this
        ## internally.  The calling API is process_form(instance,
        ## field, form) where instance should rarely be needed,
        ## field is the field object and form is the dict. of
        ## kv_pairs from the REQUEST
        ##
        ## The product of the widgets processing should be:
        ##   (value, **kwargs) which will be passed to the mutator
        ##   or None which will simply pass

        if not field.writeable(self):
            # If the field has no 'w' in mode, or the user doesn't
            # have the required permission, or the mutator doesn't
            # exist just bail out.
            continue

        try:
            # Pass validating=False to inform the widget that we
            # aren't in the validation phase, IOW, the returned
            # data will be forwarded to the storage
            result = field.widget.process_form(self,
                                               field,
                                               form,
                                               empty_marker=_marker,
                                               validating=False)
        except TypeError:
            # Support for old-style process_form methods
            result = field.widget.process_form(self,
                                               field,
                                               form,
                                               empty_marker=_marker)

        if result is _marker or result is None:
            continue

        # Set things by calling the mutator
        mutator = field.getMutator(self)
        __traceback_info__ = (self, field, mutator)
        result[1]['field'] = field.__name__
        mapply(mutator, result[0], **result[1])

    self.reindexObject()
Ejemplo n.º 5
0
 def isMultiPageSchema(self):
     return IMultiPageSchema.providedBy(self.context)
    def _processForm(self, data=1, metadata=None, REQUEST=None, values=None):
        request = REQUEST or self.REQUEST
        if values:
            form = values
        else:
            form = request.form
        fieldset = form.get('fieldset', None)
        schema = self.Schema()
        schemata = self.Schemata()
        fields = []

        if not IMultiPageSchema.providedBy(self):
            fields = schema.fields()
        elif fieldset is not None:
            fields = schemata[fieldset].fields()
        else:
            if data:
                fields += schema.filterFields(isMetadata=0)
            if metadata:
                fields += schema.filterFields(isMetadata=1)

        canonical = self.isCanonical()
        for field in fields:
            if not canonical:
                # On non-canonical items the translate screen shows language
                # independent fields in view mode. This means the form will not
                # contain their data. The contract for processForm is that
                # missing fields can be interpreted as "delete all". We need to
                # avoid this for LP or we might accidentally delete data.
                if getattr(field, 'languageIndependent', False):
                    continue

            # Delegate to the widget for processing of the form
            # element.  This means that if the widget needs _n_
            # fields under a naming convention it can handle this
            # internally.  The calling API is process_form(instance,
            # field, form) where instance should rarely be needed,
            # field is the field object and form is the dict. of
            # kv_pairs from the REQUEST
            #
            # The product of the widgets processing should be:
            #   (value, **kwargs) which will be passed to the mutator
            #   or None which will simply pass

            if not field.writeable(self):
                # If the field has no 'w' in mode, or the user doesn't
                # have the required permission, or the mutator doesn't
                # exist just bail out.
                continue

            try:
                # Pass validating=False to inform the widget that we
                # aren't in the validation phase, IOW, the returned
                # data will be forwarded to the storage
                result = field.widget.process_form(self,
                                                   field,
                                                   form,
                                                   empty_marker=_marker,
                                                   validating=False)
            except TypeError:
                # Support for old-style process_form methods
                result = field.widget.process_form(self,
                                                   field,
                                                   form,
                                                   empty_marker=_marker)

            if result is _marker or result is None:
                continue

            # Set things by calling the mutator
            mutator = field.getMutator(self)
            __traceback_info__ = (self, field, mutator)
            result[1]['field'] = field.__name__
            mapply(mutator, result[0], **result[1])

        self.reindexObject()
Ejemplo n.º 7
0
 def isMultiPageSchema(self):
     return IMultiPageSchema.providedBy(self.context)
Ejemplo n.º 8
0
 def testSurveySelectQuestion(self):
     s1 = self.s1
     s1.invokeFactory('Survey Select Question', 'ssq1')
     SurveySelectQuestionObject = getattr(s1, 'ssq1')
     assert IMultiPageSchema.providedBy(SurveySelectQuestionObject)
Ejemplo n.º 9
0
 def testSurveyMatrixQuestion(self):
     s1 = self.s1
     s1.invokeFactory('Survey Matrix', 'sm1')
     s1.sm1.invokeFactory('Survey Matrix Question', 'smq1')
     SurveyMatrixQuestionObject = getattr(s1.sm1, 'smq1')
     assert not IMultiPageSchema.providedBy(SurveyMatrixQuestionObject)
Ejemplo n.º 10
0
 def testSurveyMatrix(self):
     s1 = self.s1
     s1.invokeFactory('Survey Matrix', 'sm1')
     SurveyMatrixObject = getattr(s1, 'sm1')
     assert IMultiPageSchema.providedBy(SurveyMatrixObject)
Ejemplo n.º 11
0
 def testSubSurvey(self):
     """Sub survey doesn't seem to need to be marked with multi page schema"""
     s1 = self.s1
     s1.invokeFactory('Sub Survey', 'ss1')
     SubSurveyObject = getattr(s1, 'ss1')
     assert not IMultiPageSchema.providedBy(SubSurveyObject)
Ejemplo n.º 12
0
 def testSurvey(self):
     SurveyObject = self.s1
     assert IMultiPageSchema.providedBy(SurveyObject)