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)))
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])
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])
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)
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