diff --git a/browser/concept.py b/browser/concept.py index 76a4779..29e85ba 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -28,6 +28,7 @@ from zope.app.catalog.interfaces import ICatalog from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent from zope.app.container.contained import ObjectRemovedEvent from zope.app.form.browser.interfaces import ITerms +from zope.app.form.interfaces import IDisplayWidget from zope.app.pagetemplate import ViewPageTemplateFile from zope.cachedescriptors.property import Lazy from zope.dottedname.resolve import resolve @@ -74,12 +75,15 @@ class ConceptView(BaseView): ti = IType(self.context).typeInterface if not ti: return adapter = ti(self.context) - for f in ti: - title = getattr(ti[f], 'title', '') - value = getattr(adapter, f, '') - if not (value and title): + for n, f in schema.getFieldsInOrder(ti): + value = getattr(adapter, n, '') + if not value: continue - yield {'title': title, 'value': value, 'id': f} + bound = f.bind(adapter) + widget = component.getMultiAdapter( + (bound, self.request), IDisplayWidget) + widget.setRenderedValue(value) + yield dict(title=f.title, value=value, id=n, widget=widget) def children(self): for r in self.context.getChildRelations(): diff --git a/browser/concept_macros.pt b/browser/concept_macros.pt index ded1490..887fe55 100644 --- a/browser/concept_macros.pt +++ b/browser/concept_macros.pt @@ -9,7 +9,7 @@ : - + diff --git a/organize/configure.zcml b/organize/configure.zcml index 7dd3088..bcfbbad 100644 --- a/organize/configure.zcml +++ b/organize/configure.zcml @@ -6,7 +6,7 @@ i18n_domain="zope" > - + + + + + + + + + + + + + + + + + + + diff --git a/organize/party.py b/organize/party.py index 3a1f793..041fdfb 100644 --- a/organize/party.py +++ b/organize/party.py @@ -33,6 +33,7 @@ from zope.schema.interfaces import ValidationError from zope.app.form.interfaces import WidgetInputError from zope.security.proxy import removeSecurityProxy +from cybertools.organize.interfaces import IAddress from cybertools.organize.party import Person as BasePerson from cybertools.typology.interfaces import IType from loops.interfaces import IConcept @@ -42,7 +43,7 @@ from loops.type import TypeInterfaceSourceList, AdapterBase # register IPerson as a type interface - (TODO: use a function for this) -TypeInterfaceSourceList.typeInterfaces += (IPerson,) +TypeInterfaceSourceList.typeInterfaces += (IPerson, IAddress) class Person(AdapterBase, BasePerson): @@ -51,7 +52,7 @@ class Person(AdapterBase, BasePerson): implements(IPerson) - _attributes = ('context', '__parent__', 'userId',) + _attributes = ('context', '__parent__', 'userId', 'phoneNumbers') _schemas = list(IPerson) + list(IConcept) def getUserId(self): @@ -79,6 +80,12 @@ class Person(AdapterBase, BasePerson): pa = annotations(principal) pa[ANNOTATION_KEY] = None + def getPhoneNumbers(self): + return getattr(self.context, '_phoneNumbers', []) + def setPhoneNumbers(self, value): + self.context._phoneNumbers = value + phoneNumbers = property(getPhoneNumbers, setPhoneNumbers) + @Lazy def authentication(self): return getAuthenticationUtility(self.context) @@ -125,3 +132,19 @@ def removePersonReferenceFromPrincipal(context, event): person = IPerson(context) person.removeReferenceFromPrincipal(person.userId) + +class Address(AdapterBase): + """ typeInterface adapter for concepts of type 'address'. + """ + + implements(IAddress) + + _attributes = ('context', '__parent__', 'lines') + _schemas = list(IAddress) + list(IConcept) + + def getLines(self): + return getattr(self.context, '_lines', []) + def setLines(self, value): + self.context._lines = value + lines = property(getLines, setLines) + diff --git a/organize/task.py b/organize/task.py new file mode 100644 index 0000000..f728e0f --- /dev/null +++ b/organize/task.py @@ -0,0 +1,43 @@ +# +# Copyright (c) 2006 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Adapters for IConcept providing interfaces from the cybertools.organize package. + +$Id$ +""" + +from zope.interface import implements + +from cybertools.organize.interfaces import ITask +from loops.interfaces import IConcept +from loops.type import TypeInterfaceSourceList, AdapterBase + + +TypeInterfaceSourceList.typeInterfaces += (ITask,) + + +class Task(AdapterBase): + """ typeInterface adapter for concepts of type 'task' or 'project'. + """ + + implements(ITask) + + _attributes = ('context', '__parent__',) + _schemas = list(ITask) + list(IConcept) +