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
This commit is contained in:
parent
48f17e7b4b
commit
e95943cbf3
7 changed files with 95 additions and 50 deletions
10
README.txt
10
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', <loops.resource.Document...>)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<tal:tag condition="view/update" />
|
||||
<html metal:use-macro="context/@@standard_macros/view"
|
||||
i18n:domain="loops">
|
||||
<body>
|
||||
|
||||
<div metal:fill-slot="body">
|
||||
|
||||
<h1 tal:content="context/title">Concept Title</h1>
|
||||
|
||||
<div class="row">
|
||||
<span class="label">Parent Concepts</span>:
|
||||
<span class="field"
|
||||
tal:repeat="concept view/parents">
|
||||
<a href="#"
|
||||
tal:attributes="href string:${concept/url}/children.html">
|
||||
<span tal:replace="concept/title">parent</span>
|
||||
</a>
|
||||
<span class="field" tal:condition="not:repeat/concept/end"> - </span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row"
|
||||
tal:define="items view/children">
|
||||
<span class="label">Sub-Concepts</span>:
|
||||
<metal:children use-macro="views/relation_macros/assignments" />
|
||||
</div>
|
||||
|
||||
<form action="." method="post"
|
||||
tal:attributes="action request/URL">
|
||||
<div class="row">
|
||||
<span class="label">Concept Name</span>:
|
||||
<span class="field">
|
||||
<input type="test" name="concept_name" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="submit" name="concept_assign" value="Assign Concept" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
46
browser/concept_related.pt
Normal file
46
browser/concept_related.pt
Normal file
|
@ -0,0 +1,46 @@
|
|||
<tal:tag condition="view/update" />
|
||||
<html metal:use-macro="context/@@standard_macros/view"
|
||||
i18n:domain="loops">
|
||||
<body>
|
||||
|
||||
<div metal:fill-slot="body">
|
||||
|
||||
<h1 tal:content="context/title">Concept Title</h1><br />
|
||||
|
||||
<tal:block define="items view/parents;
|
||||
qualifier string:parents;
|
||||
legend string:Parent Concepts">
|
||||
<metal:parents use-macro="views/relation_macros/assignments" />
|
||||
</tal:block>
|
||||
<tal:block define="items view/children;
|
||||
qualifier string:children;
|
||||
legend string:Child Concepts">
|
||||
<metal:children use-macro="views/relation_macros/assignments" />
|
||||
</tal:block>
|
||||
|
||||
<form action="." method="post"
|
||||
tal:attributes="action request/URL">
|
||||
<div class="row">
|
||||
<span class="label">Concept Name</span>:
|
||||
<span class="field">
|
||||
<input type="test" name="concept_name" />
|
||||
</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<select name="concept">
|
||||
<tal:option repeat="term view/getVocabularyForRelated">
|
||||
<option tal:content="term/title"
|
||||
tal:attributes="value term/token">
|
||||
Concept Abc
|
||||
</option>
|
||||
</tal:option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="submit" name="concept_assign" value="Assign Concept" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -111,9 +111,9 @@
|
|||
permission="zope.ManageContent">
|
||||
|
||||
<page
|
||||
name="children.html"
|
||||
template="concept_children.pt"
|
||||
menu="zmi_views" title="Children"
|
||||
name="related.html"
|
||||
template="concept_related.pt"
|
||||
menu="zmi_views" title="Related Concepts"
|
||||
/>
|
||||
|
||||
</pages>
|
||||
|
@ -414,10 +414,14 @@
|
|||
|
||||
<!-- vocabulary, traversing, and other stuff -->
|
||||
|
||||
<zope:adapter factory="loops.browser.target.TargetTerms"
|
||||
<zope:adapter factory="loops.browser.terms.LoopsTerms"
|
||||
for="loops.target.TargetSourceList
|
||||
zope.publisher.interfaces.browser.IBrowserRequest" />
|
||||
|
||||
<zope:adapter factory="loops.browser.terms.LoopsTerms"
|
||||
for="loops.browser.concept.ConceptSourceList
|
||||
zope.publisher.interfaces.browser.IBrowserRequest" />
|
||||
|
||||
<zope:view factory="loops.view.NodeTraverser"
|
||||
for="loops.interfaces.INode"
|
||||
type="zope.publisher.interfaces.browser.IBrowserRequest"
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
<form method="post" name="remove" action="."
|
||||
tal:attributes="action request/URL"
|
||||
tal:condition="items">
|
||||
<input type="hidden" name="action" value="remove" />
|
||||
<input type="hidden" name="qualifier" value="parents"
|
||||
tal:attributes="value qualifier" />
|
||||
<fieldset>
|
||||
<legend tal:content="legend">Parent Concepts</legend>
|
||||
<table class="listing" summary="Currently assigned objects">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -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)
|
||||
|
Loading…
Add table
Reference in a new issue