controlling the appearance of dialog widgets
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1381 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
a44c5a1d2e
commit
eee844aaf4
3 changed files with 22 additions and 5 deletions
|
@ -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''
|
||||
|
|
|
@ -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
|
||||
|
|
11
resource.py
11
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):
|
||||
|
|
Loading…
Add table
Reference in a new issue