示例#1
0
 def update(self):
     """ Update
     """
     self.updateWidgets(prefix=self.prefix)
     groups = []
     for groupClass in self.groups:
         if IGroup.providedBy(groupClass):
             group = groupClass
         else:
             group = groupClass(self.data, self.request, self)
         group.updateWidgets(prefix=self.prefix)
         groups.append(group)
     self.groups = tuple(groups)
示例#2
0
    def uninstantiated_groups(self):
        """ Returns the number of groups which have not been instantiated by
        z3c.form.group.Group.

        """
        if not hasattr(self.form, 'groups'):
            return 0

        if not self.form.groups:
            return 0

        return sum(1 for group in self.form.groups
                   if not IGroup.providedBy(group))
 def update(self):
     """ Update
     """
     self.updateWidgets(prefix=self.prefix)
     groups = []
     for groupClass in self.groups:
         if IGroup.providedBy(groupClass):
             group = groupClass
         else:
             group = groupClass(self.data, self.request, self)
         group.updateWidgets(prefix=self.prefix)
         groups.append(group)
     self.groups = tuple(groups)
示例#4
0
    def uninstantiated_groups(self):
        """ Returns the number of groups which have not been instantiated by
        z3c.form.group.Group.

        """
        if not hasattr(self.form, 'groups'):
            return 0

        if not self.form.groups:
            return 0

        return sum(
            1 for group in self.form.groups if not IGroup.providedBy(group)
        )
示例#5
0
    def update(self):
        fieldsets=mergedTaggedValueList(self.form.schema, FIELDSETS_KEY)
        if not isinstance(self.form.groups, list):
            self.form.groups=list(self.form.groups)
        groups=dict([(group.__name__, (index, group)) for (index,group) in enumerate(self.form.groups)])
        for fieldset in fieldsets:
            layout=getattr(fieldset, "layout", None)
            if layout is None:
                continue
            if fieldset.__name__ not in groups:
                continue
            (index, group)=groups[fieldset.__name__]

            if not IGroup.providedBy(group):
                group=self.form.groups[index]=group(self.context, self.request, self.form)
            group.layout=layout
示例#6
0
    def update(self):
        fieldsets = mergedTaggedValueList(self.form.schema, FIELDSETS_KEY)
        if not isinstance(self.form.groups, list):
            self.form.groups = list(self.form.groups)
        groups = dict([(group.__name__, (index, group))
                       for (index, group) in enumerate(self.form.groups)])
        for fieldset in fieldsets:
            layout = getattr(fieldset, "layout", None)
            if layout is None:
                continue
            if fieldset.__name__ not in groups:
                continue
            (index, group) = groups[fieldset.__name__]

            if not IGroup.providedBy(group):
                group = self.form.groups[index] = group(
                    self.context, self.request, self.form)
            group.layout = layout
    def _getForm(self):
        # TODO: check if we create the form multiple times during one request
        #       and if yes, find out what needs to be updated on repeated calls
        #       e.g. context, value, mode, etc....
        # The widget provides a context for the form
        context = None
        if self.value:
            # TODO: use field here
            uri = URIRef(self.value)
            handler = getUtility(IORDF).getHandler()
            context = handler.get(URIRef(uri))
        else:
            identifier = getUtility(IORDF).generateURI()
            context = Graph(identifier=identifier)
            self.value = unicode(identifier)

        form = getattr(self, 'form', None)

        # get parent main form (we might be within a group and only main form has buttons)
        while form is not None:
            if IGroup.providedBy(form):
                form = form.__parent__
            elif IRDFObjectPropertyWidget.providedBy(form):
                form = form.form
            elif ISubForm.providedBy(form):
                form = form.__parent__
            else:
                break

        subformfactory = getMultiAdapter(
            (context,  self.request,
             form, self, self.field), ISubformFactory)
        subform = subformfactory()
        # TODO: pass on all widget properties to the form
        subform.ignoreContext = self.ignoreContext
        subform.mode = self.mode
        return subform
示例#8
0
 def is_group_form(self):
     return IGroup.providedBy(self.form)
示例#9
0
 def is_group_form(self):
     return IGroup.providedBy(self.form)