From e95943cbf306f95b95aefd7fd5cc7a9c9cae2698 Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 13 Feb 2006 18:53:58 +0000 Subject: [PATCH] Work in progress: assignment of related concepts (children and parents) to concepts git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1073 fd906abe-77d9-0310-91a1-e0d9ade77398 --- README.txt | 10 +++++-- browser/concept.py | 26 +++++++++++++++++++ browser/concept_children.pt | 42 ------------------------------ browser/concept_related.pt | 46 +++++++++++++++++++++++++++++++++ browser/configure.zcml | 12 ++++++--- browser/relation_macros.pt | 4 +++ browser/{target.py => terms.py} | 5 ++-- 7 files changed, 95 insertions(+), 50 deletions(-) delete mode 100644 browser/concept_children.pt create mode 100644 browser/concept_related.pt rename browser/{target.py => terms.py} (92%) diff --git a/README.txt b/README.txt index 901651e..459c930 100755 --- a/README.txt +++ b/README.txt @@ -80,6 +80,12 @@ Concept Views >>> sorted([c.title for c in view.children()]) [u'Zope 3'] + + >>> voc = view.getVocabularyForRelated() + >>> for term in voc: + ... print term.token, term.title + .loops/concepts/cc1 + .loops/concepts/cc2 Zope 3 Resources and what they have to do with Concepts @@ -330,8 +336,8 @@ objects.) The source is basically a source list: The form then uses a sort of browser view providing the ITerms interface based on this source list: - >>> from loops.browser.target import TargetTerms - >>> terms = TargetTerms(source, TestRequest()) + >>> from loops.browser.terms import LoopsTerms + >>> terms = LoopsTerms(source, TestRequest()) >>> term = terms.getTerm(doc1) >>> term.token, term.title, term.value ('.loops/resources/doc1', u'Zope Info', ) diff --git a/browser/concept.py b/browser/concept.py index 31a0bb2..a06b171 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -25,8 +25,11 @@ $Id$ from zope.app import zapi from zope.app.dublincore.interfaces import ICMFDublinCore from zope.cachedescriptors.property import Lazy +from zope.interface import implements +from zope import schema from zope.security.proxy import removeSecurityProxy from loops.browser.common import BaseView +from loops.browser.terms import LoopsTerms class ConceptView(BaseView): @@ -48,3 +51,26 @@ class ConceptView(BaseView): self.context.assignChild(removeSecurityProxy(concept)) return True + def getVocabularyForRelated(self): + source = ConceptSourceList(self.context) + for candidate in source: + yield LoopsTerms(ConceptView(candidate, self.request), self.request) + + +class ConceptSourceList(object): + + implements(schema.interfaces.IIterableSource) + + def __init__(self, context): + #self.context = context + self.context = removeSecurityProxy(context) + root = self.context.getLoopsRoot() + self.concepts = root.getConceptManager() + + def __iter__(self): + for obj in self.concepts.values(): + yield obj + + def __len__(self): + return len(self.concepts) + diff --git a/browser/concept_children.pt b/browser/concept_children.pt deleted file mode 100644 index 11811bf..0000000 --- a/browser/concept_children.pt +++ /dev/null @@ -1,42 +0,0 @@ - - - - -
- -

Concept Title

- -
- Parent Concepts: - - - parent - - - - -
-
- Sub-Concepts: - -
- -
-
- Concept Name: - - - -
-
- -
-
- -
- - diff --git a/browser/concept_related.pt b/browser/concept_related.pt new file mode 100644 index 0000000..c43defe --- /dev/null +++ b/browser/concept_related.pt @@ -0,0 +1,46 @@ + + + + +
+ +

Concept Title


+ + + + + + + + +
+
+ Concept Name: + + + +
+
+ +
+
+ +
+
+ +
+ + diff --git a/browser/configure.zcml b/browser/configure.zcml index a3c4ec6..58dcd26 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -111,9 +111,9 @@ permission="zope.ManageContent"> @@ -414,10 +414,14 @@ - + + + +
+ Parent Concepts diff --git a/browser/target.py b/browser/terms.py similarity index 92% rename from browser/target.py rename to browser/terms.py index b1fdb6a..bc55683 100644 --- a/browser/target.py +++ b/browser/terms.py @@ -17,7 +17,7 @@ # """ -Class(es) for representing a target attribute, to be used e.g. for +Class(es) for representing a related object , to be used e.g. for vocabularies and widgets. $Id$ @@ -29,9 +29,10 @@ from zope.schema.vocabulary import SimpleTerm from zope.cachedescriptors.property import Lazy from zope.interface import implements from zope.security.proxy import removeSecurityProxy +from loops.browser.common import BaseView -class TargetTerms(object): +class LoopsTerms(BaseView): implements(ITerms)