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
									
										
									
									
									
								
							| 
						 | 
					@ -81,6 +81,12 @@ Concept Views
 | 
				
			||||||
  >>> sorted([c.title for c in view.children()])
 | 
					  >>> sorted([c.title for c in view.children()])
 | 
				
			||||||
  [u'Zope 3']
 | 
					  [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
 | 
					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
 | 
					The form then uses a sort of browser view providing the ITerms interface
 | 
				
			||||||
based on this source list:
 | 
					based on this source list:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  >>> from loops.browser.target import TargetTerms
 | 
					  >>> from loops.browser.terms import LoopsTerms
 | 
				
			||||||
  >>> terms = TargetTerms(source, TestRequest())
 | 
					  >>> terms = LoopsTerms(source, TestRequest())
 | 
				
			||||||
  >>> term = terms.getTerm(doc1)
 | 
					  >>> term = terms.getTerm(doc1)
 | 
				
			||||||
  >>> term.token, term.title, term.value
 | 
					  >>> term.token, term.title, term.value
 | 
				
			||||||
  ('.loops/resources/doc1', u'Zope Info', <loops.resource.Document...>)
 | 
					  ('.loops/resources/doc1', u'Zope Info', <loops.resource.Document...>)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,8 +25,11 @@ $Id$
 | 
				
			||||||
from zope.app import zapi
 | 
					from zope.app import zapi
 | 
				
			||||||
from zope.app.dublincore.interfaces import ICMFDublinCore
 | 
					from zope.app.dublincore.interfaces import ICMFDublinCore
 | 
				
			||||||
from zope.cachedescriptors.property import Lazy
 | 
					from zope.cachedescriptors.property import Lazy
 | 
				
			||||||
 | 
					from zope.interface import implements
 | 
				
			||||||
 | 
					from zope import schema
 | 
				
			||||||
from zope.security.proxy import removeSecurityProxy
 | 
					from zope.security.proxy import removeSecurityProxy
 | 
				
			||||||
from loops.browser.common import BaseView
 | 
					from loops.browser.common import BaseView
 | 
				
			||||||
 | 
					from loops.browser.terms import LoopsTerms
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ConceptView(BaseView):
 | 
					class ConceptView(BaseView):
 | 
				
			||||||
| 
						 | 
					@ -48,3 +51,26 @@ class ConceptView(BaseView):
 | 
				
			||||||
            self.context.assignChild(removeSecurityProxy(concept))
 | 
					            self.context.assignChild(removeSecurityProxy(concept))
 | 
				
			||||||
        return True
 | 
					        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">
 | 
					      permission="zope.ManageContent">
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    <page
 | 
					    <page
 | 
				
			||||||
        name="children.html"
 | 
					        name="related.html"
 | 
				
			||||||
        template="concept_children.pt"
 | 
					        template="concept_related.pt"
 | 
				
			||||||
        menu="zmi_views" title="Children"
 | 
					        menu="zmi_views" title="Related Concepts"
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  </pages>
 | 
					  </pages>
 | 
				
			||||||
| 
						 | 
					@ -414,10 +414,14 @@
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  <!-- vocabulary, traversing, and other stuff -->
 | 
					  <!-- vocabulary, traversing, and other stuff -->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <zope:adapter factory="loops.browser.target.TargetTerms"
 | 
					  <zope:adapter factory="loops.browser.terms.LoopsTerms"
 | 
				
			||||||
           for="loops.target.TargetSourceList
 | 
					           for="loops.target.TargetSourceList
 | 
				
			||||||
                zope.publisher.interfaces.browser.IBrowserRequest" />
 | 
					                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"
 | 
					  <zope:view factory="loops.view.NodeTraverser"
 | 
				
			||||||
        for="loops.interfaces.INode"
 | 
					        for="loops.interfaces.INode"
 | 
				
			||||||
        type="zope.publisher.interfaces.browser.IBrowserRequest"
 | 
					        type="zope.publisher.interfaces.browser.IBrowserRequest"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,11 @@
 | 
				
			||||||
  <form method="post" name="remove" action="."
 | 
					  <form method="post" name="remove" action="."
 | 
				
			||||||
        tal:attributes="action request/URL"
 | 
					        tal:attributes="action request/URL"
 | 
				
			||||||
        tal:condition="items">
 | 
					        tal:condition="items">
 | 
				
			||||||
 | 
					    <input type="hidden" name="action" value="remove" />
 | 
				
			||||||
 | 
					    <input type="hidden" name="qualifier" value="parents"
 | 
				
			||||||
 | 
					           tal:attributes="value qualifier" />
 | 
				
			||||||
    <fieldset>
 | 
					    <fieldset>
 | 
				
			||||||
 | 
					     <legend tal:content="legend">Parent Concepts</legend>
 | 
				
			||||||
      <table class="listing" summary="Currently assigned objects">
 | 
					      <table class="listing" summary="Currently assigned objects">
 | 
				
			||||||
        <thead>
 | 
					        <thead>
 | 
				
			||||||
          <tr>
 | 
					          <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.
 | 
					vocabularies and widgets.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$Id$
 | 
					$Id$
 | 
				
			||||||
| 
						 | 
					@ -29,9 +29,10 @@ from zope.schema.vocabulary import SimpleTerm
 | 
				
			||||||
from zope.cachedescriptors.property import Lazy
 | 
					from zope.cachedescriptors.property import Lazy
 | 
				
			||||||
from zope.interface import implements
 | 
					from zope.interface import implements
 | 
				
			||||||
from zope.security.proxy import removeSecurityProxy
 | 
					from zope.security.proxy import removeSecurityProxy
 | 
				
			||||||
 | 
					from loops.browser.common import BaseView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TargetTerms(object):
 | 
					class LoopsTerms(BaseView):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    implements(ITerms)
 | 
					    implements(ITerms)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue