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.resource import IndexAttributes
|
||||||
|
>>> from loops.type import LoopsType
|
||||||
|
>>> component.provideAdapter(LoopsType)
|
||||||
>>> idx = IndexAttributes(doc1)
|
>>> idx = IndexAttributes(doc1)
|
||||||
>>> idx.text()
|
>>> idx.text()
|
||||||
u''
|
u''
|
||||||
|
|
|
@ -57,8 +57,9 @@ class ObjectForm(NodeView):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.setUpWidgets()
|
self.setUpWidgets()
|
||||||
# TODO: such stuff should depend on self.typeInterface
|
if self.typeInterface in widgetControllers:
|
||||||
self.widgets['data'].height = 3
|
wc = widgetControllers[self.typeInterface]()
|
||||||
|
wc.modifyWidgetSetup(self.widgets)
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
return innerHtml(self)
|
return innerHtml(self)
|
||||||
|
@ -69,6 +70,15 @@ class ObjectForm(NodeView):
|
||||||
self.loopsRoot.getConceptManager().getDefaultPredicate())
|
self.loopsRoot.getConceptManager().getDefaultPredicate())
|
||||||
|
|
||||||
|
|
||||||
|
class NoteWidgetController(object):
|
||||||
|
|
||||||
|
def modifyWidgetSetup(self, widgets):
|
||||||
|
widgets['data'].height = 5
|
||||||
|
|
||||||
|
|
||||||
|
widgetControllers = {INote: NoteWidgetController}
|
||||||
|
|
||||||
|
|
||||||
class EditObjectForm(ObjectForm, EditForm):
|
class EditObjectForm(ObjectForm, EditForm):
|
||||||
|
|
||||||
@property
|
@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.registry import getRelations
|
||||||
from cybertools.relation.interfaces import IRelatable
|
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 IBaseResource, IResource
|
||||||
from interfaces import IFile, INote
|
from interfaces import IFile, INote
|
||||||
|
@ -251,13 +251,18 @@ class IndexAttributes(object):
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
context = self.context
|
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'):
|
if not context.contentType.startswith('text'):
|
||||||
return u''
|
return u''
|
||||||
data = context.data
|
data = context.data
|
||||||
if type(data) != unicode:
|
if type(data) != unicode:
|
||||||
data = data.decode('UTF-8')
|
data = data.decode('UTF-8')
|
||||||
# TODO: transform to plain text
|
|
||||||
#return ' '.join((zapi.getName(context), context.title, data)).strip()
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def title(self):
|
def title(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue