From eee844aaf4ab547d5fc56243b4e2088004792bbd Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 2 Oct 2006 15:55:23 +0000 Subject: [PATCH] controlling the appearance of dialog widgets git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1381 fd906abe-77d9-0310-91a1-e0d9ade77398 --- README.txt | 2 ++ browser/form.py | 14 ++++++++++++-- resource.py | 11 ++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index 2feaa8b..25f1ed7 100755 --- a/README.txt +++ b/README.txt @@ -317,6 +317,8 @@ Index attributes adapter ------------------------ >>> from loops.resource import IndexAttributes + >>> from loops.type import LoopsType + >>> component.provideAdapter(LoopsType) >>> idx = IndexAttributes(doc1) >>> idx.text() u'' diff --git a/browser/form.py b/browser/form.py index 1909696..a2edd56 100644 --- a/browser/form.py +++ b/browser/form.py @@ -57,8 +57,9 @@ class ObjectForm(NodeView): def setUp(self): self.setUpWidgets() - # TODO: such stuff should depend on self.typeInterface - self.widgets['data'].height = 3 + if self.typeInterface in widgetControllers: + wc = widgetControllers[self.typeInterface]() + wc.modifyWidgetSetup(self.widgets) def __call__(self): return innerHtml(self) @@ -69,6 +70,15 @@ class ObjectForm(NodeView): self.loopsRoot.getConceptManager().getDefaultPredicate()) +class NoteWidgetController(object): + + def modifyWidgetSetup(self, widgets): + widgets['data'].height = 5 + + +widgetControllers = {INote: NoteWidgetController} + + class EditObjectForm(ObjectForm, EditForm): @property diff --git a/resource.py b/resource.py index b3066e0..e8d80e6 100644 --- a/resource.py +++ b/resource.py @@ -42,7 +42,7 @@ from zope.event import notify from cybertools.relation.registry import getRelations from cybertools.relation.interfaces import IRelatable -from cybertools.typology.interfaces import ITypeManager +from cybertools.typology.interfaces import IType, ITypeManager from interfaces import IBaseResource, IResource from interfaces import IFile, INote @@ -251,13 +251,18 @@ class IndexAttributes(object): def text(self): context = self.context + ti = IType(context).typeInterface + if ti is not None: + adapted = ti(context) + #transform = component.queryAdapter( + # adapted, ITextTransform, name=context.contentType) + #if transform is not None: + # return transform() if not context.contentType.startswith('text'): return u'' data = context.data if type(data) != unicode: data = data.decode('UTF-8') - # TODO: transform to plain text - #return ' '.join((zapi.getName(context), context.title, data)).strip() return data def title(self):