diff --git a/README.txt b/README.txt index e8df8c4..0a344cd 100755 --- a/README.txt +++ b/README.txt @@ -48,30 +48,35 @@ testing we use a simple dummy implementation. >>> from zope.app.testing import ztapi >>> ztapi.provideUtility(IRelationRegistry, DummyRelationRegistry()) -Now we can assign the concept c2 to c1 (using the standard ConceptRelation): +Now we can assign the concept c2 as a child to c1 (using the standard +ConceptRelation): - >>> cc1.assignConcept(cc2) + >>> cc1.assignChild(cc2) -We can now ask our concepts for their related concepts: +We can now ask our concepts for their related child and parent concepts: - >>> sc1 = cc1.getSubConcepts() + >>> sc1 = cc1.getChildren() >>> len(sc1) 1 >>> cc2 in sc1 True - >>> len(cc1.getParentConcepts()) + >>> len(cc1.getParents()) 0 - >>> pc2 = cc2.getParentConcepts() + >>> pc2 = cc2.getParents() >>> len(pc2) 1 >>> cc1 in pc2 True - >>> len(cc2.getSubConcepts()) + >>> len(cc2.getChildren()) 0 -TODO: Work with views... +Concept Views +------------- + + >>> from loops.browser.concept import ConceptView + >>> view = ConceptView(cc1, TestRequest()) Resources and what they have to do with Concepts @@ -147,12 +152,15 @@ Views/Nodes: Menus, Menu Items, Listings, Pages, etc ==================================================== Note: the term "view" here is not directly related to the special -Zop 3 term "view" (a multiadapter for presentation purposes) but basically +Zope 3 term "view" (a multiadapter for presentation purposes) but basically bears the common sense meaning: an object (that may be persistent or created on the fly) that provides a view to content of whatever kind. Views (or nodes - that's the only type of views existing at the moment) -thus provide the presentation space to concepts and resources. +thus provide the presentation space for concepts and resources, i.e. visitors +of a site only see views or nodes but never concepts or resources directly; +the views or nodes, however, present informations coming from the concepts +or resources they are related to. We first need a view manager: @@ -333,7 +341,7 @@ based on this source list: True There is a special edit view class that can be used to configure a node -in a way, that allows the creation of a target object on the fly. +in a way that allows the creation of a target object on the fly. (We here use the base class providing the method for this action; the real application uses a subclass that does all the other stuff for form handling.) When creating a new target object you may specify a uri that determines @@ -440,6 +448,10 @@ cybertools.relation package.) Ordering Nodes -------------- +Note: this functionality has been moved to cybertools.container; we +include some testing here to make sure it still works and give a short +demonstration. + Let's add some more nodes and reorder them: >>> m113 = Node() diff --git a/browser/concept_details.pt b/browser/concept.pt similarity index 91% rename from browser/concept_details.pt rename to browser/concept.pt index 007e086..676ce76 100644 --- a/browser/concept_details.pt +++ b/browser/concept.pt @@ -11,7 +11,7 @@
Sub-Concepts: + tal:repeat="concept view/children"> subtask @@ -21,7 +21,7 @@
Parent Concepts: + tal:repeat="concept view/parents"> subtask diff --git a/browser/concept.py b/browser/concept.py index 3688804..585f6ad 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -24,13 +24,16 @@ $Id$ from zope.app import zapi from zope.app.dublincore.interfaces import ICMFDublinCore +from zope.cachedescriptors.property import Lazy from zope.security.proxy import removeSecurityProxy -from cybertools.relation import DyadicRelation -from loops.interfaces import IConcept +class ConceptView(object): -class Details(object): + def __init__(self, context, request): + self.context = context + self.request = request + @Lazy def modified(self): """ get date/time of last modification """ @@ -38,25 +41,28 @@ class Details(object): d = dc.modified or dc.created return d and d.strftime('%Y-%m-%d %H:%M') or '' - def subConcepts(self): - return [{'object': c, - 'title': c.title, - 'url': zapi.absoluteURL(c, self.request)} - for c in self.context.getSubConcepts()] + @Lazy + def url(self): + return zapi.absoluteURL(self.context, self.request) - def parentConcepts(self): - return [{'object': c, - 'title': c.title, - 'url': zapi.absoluteURL(c, self.request)} - for c in self.context.getParentConcepts()] + @Lazy + def title(self): + return self.context.title + def children(self): + request = self.request + for c in self.context.getChildren(): + yield ConceptView(c, request) -class ConceptRelations(Details): + def parents(self): + request = self.request + for c in self.context.getParents(): + yield ConceptView(c, request) - def assignConcept(self, concept_name): - """ Assign a concept denoted by the 'concept_name' request parameter. - """ - concept = zapi.getParent(self.context)[concept_name] - self.context.assignConcept(removeSecurityProxy(concept)) - self.request.response.redirect(zapi.absoluteURL(self.context, self.request)) + def update(self): + concept_name = self.request.get('concept_name', None) + if concept_name: + concept = zapi.getParent(self.context)[concept_name] + self.context.assignChild(removeSecurityProxy(concept)) + return True diff --git a/browser/concept_assign.pt b/browser/concept_children.pt similarity index 55% rename from browser/concept_assign.pt rename to browser/concept_children.pt index 7b5ad10..2150aad 100644 --- a/browser/concept_assign.pt +++ b/browser/concept_children.pt @@ -1,9 +1,8 @@ - - - - + + +

Concept Title

@@ -11,28 +10,30 @@
Sub-Concepts: + tal:repeat="concept view/children"> **deleted** - subconcept + + child + -
Parent Concepts: - parent concept + tal:repeat="concept view/parents"> + + parent + -
-
- Last Modified: - 2004-08-28 -
+ tal:attributes="action request/URL">
Concept Name: @@ -40,7 +41,7 @@
- +
diff --git a/browser/configure.zcml b/browser/configure.zcml index 0e1ff43..8cef02b 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -72,20 +72,6 @@ - - - - - - + + + + + + - - + + i18n:domain="zope"> + + + + + + - - - - - +
-