From 0c6d0a410232781077f73b0b5554ba6a46e4e106 Mon Sep 17 00:00:00 2001 From: helmutm Date: Wed, 7 Mar 2007 17:23:13 +0000 Subject: [PATCH] Make contentType field editable under certain circumstances git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1625 fd906abe-77d9-0310-91a1-e0d9ade77398 --- browser/form.py | 12 +++++++++--- concept.py | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/browser/form.py b/browser/form.py index 4b0790c..3a68304 100644 --- a/browser/form.py +++ b/browser/form.py @@ -88,7 +88,7 @@ class ObjectForm(NodeView): if desc: desc.height = 2 if self.typeInterface in widgetControllers: - wc = widgetControllers[self.typeInterface]() + wc = widgetControllers[self.typeInterface](self.context, self.request) wc.modifyWidgetSetup(self.widgets) def __call__(self): @@ -124,6 +124,10 @@ class ObjectForm(NodeView): class WidgetController(object): + def __init__(self, context, request): + self.context = context + self.request = request + def modifyFormFields(self, formFields): return formFields @@ -143,6 +147,8 @@ class NoteWidgetController(WidgetController): class FileWidgetController(WidgetController): def modifyFormFields(self, formFields): + if self.request.principal.id == 'rootadmin': + return formFields return formFields.omit('contentType') @@ -174,7 +180,7 @@ class EditObjectForm(ObjectForm, EditForm): def form_fields(self): ff = FormFields(self.typeInterface) if self.typeInterface in widgetControllers: - wc = widgetControllers[self.typeInterface]() + wc = widgetControllers[self.typeInterface](self.context, self.request) ff = wc.modifyFormFields(ff) return ff @@ -207,7 +213,7 @@ class CreateObjectForm(ObjectForm, Form): ff = FormFields(ifc) #ff['data'].custom_widget = UploadWidget if self.typeInterface in widgetControllers: - wc = widgetControllers[self.typeInterface]() + wc = widgetControllers[self.typeInterface](self.context, self.request) ff = wc.modifyFormFields(ff) return ff diff --git a/concept.py b/concept.py index ad236ae..ac6c7bb 100644 --- a/concept.py +++ b/concept.py @@ -63,6 +63,12 @@ class BaseRelation(DyadicRelation): id = zapi.getUtility(IRelationRegistry).getUniqueIdForObject(self.predicate) return '.'.join((baseName, str(id))) + # Problem with reindex catalog, needs __parent__ - but this does not help: + #__parent__ = None + #@property + #def __parent__(self): + # return self.first + class ConceptRelation(BaseRelation): """ A relation between concept objects.