コード例 #1
0
ファイル: results.py プロジェクト: Zojax/zojax.askexpert
 def getFieldData(field, fields):
     fieldId = field.__name__
     if fieldId not in record:
         return
     if IRichText.providedBy(field):
         fields.append((field.title, record.pop(fieldId).text))
     elif IField.providedBy(field):
         fields.append((field.title, record.pop(fieldId)))
コード例 #2
0
ファイル: vocabulary.py プロジェクト: Zojax/zojax.formulator
    def __call__(self, context):
        form = context
        while not IForm.providedBy(form):
            form = getattr(form, '__parent__', None)
            if form is None:
                return SimpleVocabulary(())

        fields = []
        for name, field in form.items():
            if IField.providedBy(field):
                fields.append((field.title, field.__name__))

        fields.sort()
        return Vocabulary(
            [SimpleTerm(name, name, title) for title, name in fields])
コード例 #3
0
ファイル: vocabulary.py プロジェクト: Zojax/zojax.askexpert
    def __call__(self, context):
        form = context
        ids = component.getUtility(IIntIds)
        while not IForm.providedBy(form):
            form = getattr(form, "__parent__", None)
            if form is None:
                return SimpleVocabulary(())

        fields = []
        for name, field in form.items():
            if IField.providedBy(field):
                fields.append((field.title, ids.getId(removeAllProxies(field))))

        fields.sort()
        return Vocabulary([SimpleTerm(id, id, title) for title, id in fields])
コード例 #4
0
ファイル: form.py プロジェクト: Zojax/zojax.askexpert
    def fields(self):
        form = self.context
        order = IOrder(form)
        ids = component.getUtility(IIntIds)

        groupFields = []
        for grp in order.values():
            if IGroup.providedBy(grp):
                for id in grp.fields:
                    try:
                        field = ids.getObject(id)
                    except (TypeError, KeyError), e:
                        continue
                    fieldId = field.__name__
                    if IField.providedBy(field):
                        groupFields.append(fieldId)
コード例 #5
0
ファイル: form.py プロジェクト: Zojax/zojax.askexpert
    def groups(self):
        form = self.context
        ids = component.getUtility(IIntIds)
        groups = []
        for grp in self.context.values():
            if IGroup.providedBy(grp):
                fields = []
                for id in grp.fields:
                    try:
                        field = ids.getObject(id)
                    except (TypeError, KeyError):
                        continue
                    fieldId = field.__name__
                    if IField.providedBy(field):
                        fields.append(field)
                fields = Fields(*fields)

                grpCls = type(str(grp.__name__), (group.Group,),
                              {'label': grp.title,
                               'description': grp.description, 'fields': fields})
                groups.append(grpCls)
        return groups