diff --git a/browser/common.py b/browser/common.py index f38618c..4e7da1c 100644 --- a/browser/common.py +++ b/browser/common.py @@ -40,6 +40,7 @@ from zope.schema.vocabulary import SimpleTerm from zope.security import canAccess, canWrite from zope.security.proxy import removeSecurityProxy from zope.traversing.browser import absoluteURL +from zope.traversing.api import getName from cybertools.browser.view import GenericView from cybertools.relation.interfaces import IRelationRegistry @@ -126,7 +127,11 @@ class BaseView(GenericView): @Lazy def title(self): - return self.context.title or zapi.getName(self.context) + return self.context.title or getName(self.context) + + @Lazy + def description(self): + return self.context.description @Lazy def dcTitle(self): diff --git a/browser/concept.py b/browser/concept.py index ee0be16..7a5eacb 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -62,6 +62,12 @@ class ConceptEditForm(EditForm): fields = FormFields(fields, typeInterface) return fields + def setUpWidgets(self, ignore_request=False): + super(ConceptEditForm, self).setUpWidgets(ignore_request) + desc = self.widgets.get('description') + if desc: + desc.height = 2 + class ConceptView(BaseView): @@ -71,6 +77,14 @@ class ConceptView(BaseView): def macro(self): return self.template.macros['conceptdata'] + def __init__(self, context, request): + super(ConceptView, self).__init__(context, request) + cont = self.controller + if cont is not None: + cont.macros.register('portlet_right', 'parents', title='Parents', + subMacro=self.template.macros['parents'], + position=0, info=self) + def fieldData(self): ti = IType(self.context).typeInterface if not ti: return diff --git a/browser/concept_macros.pt b/browser/concept_macros.pt index 8bc3c02..1e121e8 100644 --- a/browser/concept_macros.pt +++ b/browser/concept_macros.pt @@ -1,21 +1,9 @@
-
-
- -
-
- - -
-
- -
-
-
+ +
+
-
@@ -39,41 +27,68 @@ -
- Parents +
+

Parents

Concept Title
-
+
-
- Children -
+
+

Children


+
Concept Title
-
+
-
- Resources -
- Resource Title -
-
+
+

Resources


+ + + + + + + + + + + + + + + + + + +
TitleTypeModification Date
+ + Resource Title + + TypeType
+ describing... +
+
@@ -87,3 +102,18 @@ + + + + + +
+ + Concept + (Type) + +
+
+ + diff --git a/browser/configure.zcml b/browser/configure.zcml index 9da785b..9eb76f0 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -333,27 +333,6 @@ permission="zope.View" /> - - - - - - - -

Title

+

Description

diff --git a/concept.py b/concept.py index 4889ee9..ad236ae 100644 --- a/concept.py +++ b/concept.py @@ -22,6 +22,7 @@ Definition of the Concept and related classes. $Id$ """ +from zope import component, schema from zope.app import zapi from zope.app.container.btree import BTreeContainer from zope.app.container.contained import Contained @@ -29,8 +30,8 @@ from zope.cachedescriptors.property import Lazy from zope.component import adapts from zope.interface import implements from zope.interface import alsoProvides, directlyProvides, directlyProvidedBy -from zope import schema from zope.security.proxy import removeSecurityProxy +from zope.traversing.api import getName from persistent import Persistent from cybertools.relation import DyadicRelation @@ -83,11 +84,19 @@ class Concept(Contained, Persistent): proxyInterface = IConceptView + def __init__(self, title=u''): + self.title = title + _title = u'' def getTitle(self): return self._title def setTitle(self, title): self._title = title title = property(getTitle, setTitle) + _description = u'' + def getDescription(self): return self._description + def setDescription(self, description): self._description = description + description = property(getDescription, setDescription) + def getConceptType(self): typePred = self.getConceptManager().getTypePredicate() if typePred is None: @@ -107,9 +116,6 @@ class Concept(Contained, Persistent): self.assignParent(concept, typePred) conceptType = property(getConceptType, setConceptType) - def __init__(self, title=u''): - self.title = title - def getLoopsRoot(self): return zapi.getParent(self).getLoopsRoot() @@ -299,9 +305,10 @@ class IndexAttributes(object): def text(self): context = self.context # TODO: include attributes provided by concept type - return ' '.join((zapi.getName(context), context.title,)) + return ' '.join((getName(context), context.title,)) def title(self): context = self.context - return ' '.join((zapi.getName(context), context.title,)) + return ' '.join((getName(context), + context.title, context.description)).strip() diff --git a/interfaces.py b/interfaces.py index 061ce98..0db4d8f 100644 --- a/interfaces.py +++ b/interfaces.py @@ -74,6 +74,14 @@ class IConcept(ILoopsObject, IPotentialTarget): default=u'', required=True) + description = schema.Text( + title=_(u'Description'), + description=_(u'A medium-length description describing the ' + 'content and the purpose of the object'), + default=u'', + missing_value=u'', + required=False) + conceptType = schema.Choice( title=_(u'Concept Type'), description=_(u"The type of the concept, specified by a relation to " @@ -199,6 +207,14 @@ class IBaseResource(ILoopsObject): missing_value=u'', required=True) + description = schema.Text( + title=_(u'Description'), + description=_(u'A medium-length description describing the ' + 'content and the purpose of the object'), + default=u'', + missing_value=u'', + required=False) + resourceType = schema.Choice( title=_(u'Resource Type'), description=_(u"The type of the resource, specified by a relation to " @@ -237,6 +253,14 @@ class IResourceSchema(Interface): missing_value=u'', required=True) + description = schema.Text( + title=_(u'Description'), + description=_(u'A medium-length description describing the ' + 'content and the purpose of the object'), + default=u'', + missing_value=u'', + required=False) + data = schema.Bytes( title=_(u'Data'), description=_(u'Resource raw data'), @@ -312,7 +336,7 @@ class IDocument(IDocumentSchema, IResource): """ -# media asset is probably obsolete - replaced by plain Resource with +# media asset is obsolete - replaced by plain Resource with # resourceType = file. class IMediaAssetView(IResourceSchema): diff --git a/organize/member.py b/organize/member.py index 121b88a..785bb71 100644 --- a/organize/member.py +++ b/organize/member.py @@ -62,6 +62,7 @@ class MemberRegistrationManager(object): # step 2: create a corresponding person concept: cm = self.context.getConceptManager() id = baseId = 'person.' + userId + # TODO: use NameChooser num = 0 while id in cm: num +=1 diff --git a/resource.py b/resource.py index 6f071b1..a51135a 100644 --- a/resource.py +++ b/resource.py @@ -22,19 +22,19 @@ Definition of the Concept class. $Id$ """ -from zope import component +from zope import component, schema from zope.app import zapi from zope.app.container.btree import BTreeContainer from zope.app.container.contained import Contained from zope.app.file.image import Image from zope.app.file.interfaces import IFile from zope.filerepresentation.interfaces import IReadFile, IWriteFile -from zope.size.interfaces import ISized from zope.cachedescriptors.property import Lazy from zope.component import adapts from zope.i18nmessageid import MessageFactory from zope.interface import implements -from zope import schema +from zope.size.interfaces import ISized +from zope.traversing.api import getName from persistent import Persistent from cStringIO import StringIO @@ -78,7 +78,7 @@ class Resource(Image, Contained): implements(IBaseResource, IResource, IResourceManagerContained, IRelatable, ISized) - proxyInterface = IMediaAssetView + proxyInterface = IMediaAssetView # obsolete! _size = _width = _height = 0 @@ -86,6 +86,16 @@ class Resource(Image, Contained): super(Resource, self).__init__() self.title = title + _title = u'' + def getTitle(self): return self._title + def setTitle(self, title): self._title = title + title = property(getTitle, setTitle) + + _description = u'' + def getDescription(self): return self._description + def setDescription(self, description): self._description = description + description = property(getDescription, setDescription) + def getResourceType(self): cm = self.getLoopsRoot().getConceptManager() typePred = cm.getTypePredicate() @@ -108,11 +118,6 @@ class Resource(Image, Contained): self.assignConcept(concept, typePred) resourceType = property(getResourceType, setResourceType) - _title = u'' - def getTitle(self): return self._title - def setTitle(self, title): self._title = title - title = property(getTitle, setTitle) - def _setData(self, data): dataFile = StringIO(data) # let File tear it into pieces super(Resource, self)._setData(dataFile) @@ -342,7 +347,8 @@ class IndexAttributes(object): def title(self): context = self.context - return ' '.join((zapi.getName(context), context.title,)).strip() + return ' '.join((getName(context), + context.title, context.description)).strip() class ResourceTypeSourceList(object):