Added loops top-level container, managers, resources...
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@814 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									8ab66daf29
								
							
						
					
					
						commit
						a659d8c7de
					
				
					 9 changed files with 486 additions and 22 deletions
				
			
		
							
								
								
									
										18
									
								
								README.txt
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								README.txt
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -3,17 +3,25 @@ loops - Linked Objects for Organizational Process Services
 | 
			
		|||
 | 
			
		||||
  ($Id$)
 | 
			
		||||
 | 
			
		||||
Concepts and Relations
 | 
			
		||||
~~~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
Concepts and Relations between them
 | 
			
		||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 | 
			
		||||
 | 
			
		||||
Let's start with creating a few example concepts:
 | 
			
		||||
Let's start with creating a few example concepts, putting them in a
 | 
			
		||||
top-level loops container and a concept manager:
 | 
			
		||||
 | 
			
		||||
    >>> from loops.concept import Concept
 | 
			
		||||
    >>> from loops import Loops
 | 
			
		||||
    >>> loops = Loops()
 | 
			
		||||
        
 | 
			
		||||
    >>> from loops.concept import ConceptManager, Concept
 | 
			
		||||
    >>> loops['concepts'] = ConceptManager()
 | 
			
		||||
    >>> concepts = loops['concepts']
 | 
			
		||||
    >>> c1 = Concept()
 | 
			
		||||
    >>> concepts['c1'] = c1
 | 
			
		||||
    >>> c1.title
 | 
			
		||||
    u''
 | 
			
		||||
 | 
			
		||||
    >>> c2 = Concept(u'c2', u'Second Concept')
 | 
			
		||||
    >>> concepts['c2'] = c2
 | 
			
		||||
    >>> c2.title
 | 
			
		||||
    u'Second Concept'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +41,7 @@ We also need a Relation class to be used for connecting concepts:
 | 
			
		|||
 | 
			
		||||
Now we can assign the concept c2 to c1:
 | 
			
		||||
        
 | 
			
		||||
    >>> c1.assignConcept(c2, DyadicRelation)
 | 
			
		||||
    >>> c1.assignConcept(c2)
 | 
			
		||||
 | 
			
		||||
We can now ask our concepts for their related concepts:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										29
									
								
								__init__.py
									
										
									
									
									
								
							
							
						
						
									
										29
									
								
								__init__.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,33 @@
 | 
			
		|||
# -*- coding: UTF-8 -*-
 | 
			
		||||
# -*- Mode: Python; py-indent-offset: 4 -*-
 | 
			
		||||
#
 | 
			
		||||
#  Copyright (c) 2005 Helmut Merz helmutm@cy55.de
 | 
			
		||||
#
 | 
			
		||||
#  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#  it under the terms of the GNU General Public License as published by
 | 
			
		||||
#  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#  (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#  This program is distributed in the hope that it will be useful,
 | 
			
		||||
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#  GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#  You should have received a copy of the GNU General Public License
 | 
			
		||||
#  along with this program; if not, write to the Free Software
 | 
			
		||||
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
$Id$
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from zope.app.folder.folder import Folder
 | 
			
		||||
from interfaces import ILoops
 | 
			
		||||
 | 
			
		||||
class Loops(Folder):
 | 
			
		||||
 | 
			
		||||
    implements(ILoops)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,50 @@
 | 
			
		|||
   i18n_domain="zope"
 | 
			
		||||
   >
 | 
			
		||||
 | 
			
		||||
  <!-- loops top-level container -->
 | 
			
		||||
 | 
			
		||||
  <addform
 | 
			
		||||
      label="Add loops Container"
 | 
			
		||||
      name="AddLoopsContainer.html"
 | 
			
		||||
      schema="loops.interfaces.ILoops"
 | 
			
		||||
      content_factory="loops.Loops"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <addMenuItem
 | 
			
		||||
      class="loops.Loops"
 | 
			
		||||
      title="loops Container"
 | 
			
		||||
      description="A top-level loops container"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      view="AddLoopsContainer.html"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <!-- concept manager -->
 | 
			
		||||
 | 
			
		||||
  <addform
 | 
			
		||||
      label="Add Concept Manager"
 | 
			
		||||
      name="AddLoopsConceptManager.html"
 | 
			
		||||
      schema="loops.interfaces.IConceptManager"
 | 
			
		||||
      content_factory="loops.concept.ConceptManager"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <addMenuItem
 | 
			
		||||
      class="loops.concept.ConceptManager"
 | 
			
		||||
      title="Concept Manager"
 | 
			
		||||
      description="A concept manager manages concepts"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      view="AddLoopsConceptManager.html"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <containerViews
 | 
			
		||||
      for="loops.interfaces.IConceptManager"
 | 
			
		||||
      contents="zope.View"
 | 
			
		||||
      add="zope.ManageContent"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <!-- concept -->
 | 
			
		||||
 | 
			
		||||
  <page
 | 
			
		||||
      name="details.html"
 | 
			
		||||
      for="loops.interfaces.IConcept"
 | 
			
		||||
| 
						 | 
				
			
			@ -65,4 +109,56 @@
 | 
			
		|||
 | 
			
		||||
  </pages>
 | 
			
		||||
    
 | 
			
		||||
  <!-- resource manager -->
 | 
			
		||||
 | 
			
		||||
  <addform
 | 
			
		||||
      label="Add Resource Manager"
 | 
			
		||||
      name="AddLoopsResourceManager.html"
 | 
			
		||||
      schema="loops.interfaces.IResourceManager"
 | 
			
		||||
      content_factory="loops.resource.ResourceManager"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <addMenuItem
 | 
			
		||||
      class="loops.resource.ResourceManager"
 | 
			
		||||
      title="Resource Manager"
 | 
			
		||||
      description="A resource manager manages resources"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      view="AddLoopsResourceManager.html"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <containerViews
 | 
			
		||||
      for="loops.interfaces.IResourceManager"
 | 
			
		||||
      contents="zope.View"
 | 
			
		||||
      add="zope.ManageContent"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <!-- document -->
 | 
			
		||||
 | 
			
		||||
  <addform
 | 
			
		||||
      label="Add Document"
 | 
			
		||||
      name="AddLoopsDocument.html"
 | 
			
		||||
      schema="loops.interfaces.IDocument"
 | 
			
		||||
      content_factory="loops.resource.Document"
 | 
			
		||||
      fields="title body format"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <addMenuItem
 | 
			
		||||
      class="loops.resource.Document"
 | 
			
		||||
      title="Document"
 | 
			
		||||
      description="A document is an editable information unit"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      view="AddLoopsDocument.html"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
  <editform
 | 
			
		||||
      label="Edit Document"
 | 
			
		||||
      name="edit.html"
 | 
			
		||||
      schema="loops.interfaces.IDocument"
 | 
			
		||||
      for="loops.interfaces.IDocument"
 | 
			
		||||
      permission="zope.ManageContent"
 | 
			
		||||
      menu="zmi_views" title="Edit"
 | 
			
		||||
      />
 | 
			
		||||
 | 
			
		||||
</configure>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										17
									
								
								concept.py
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								concept.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -23,6 +23,7 @@ $Id$
 | 
			
		|||
"""
 | 
			
		||||
 | 
			
		||||
from zope.app import zapi
 | 
			
		||||
from zope.app.container.btree import BTreeContainer
 | 
			
		||||
from zope.app.container.contained import Contained
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from persistent import Persistent
 | 
			
		||||
| 
						 | 
				
			
			@ -31,11 +32,14 @@ from cybertools.relation.interfaces import IRelationsRegistry
 | 
			
		|||
from cybertools.relation import DyadicRelation
 | 
			
		||||
 | 
			
		||||
from interfaces import IConcept
 | 
			
		||||
from interfaces import IConceptManager, IConceptManagerContained
 | 
			
		||||
from interfaces import ILoopsContained
 | 
			
		||||
from relations import ConceptRelation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Concept(Persistent, Contained):
 | 
			
		||||
class Concept(Contained, Persistent):
 | 
			
		||||
 | 
			
		||||
    implements(IConcept)
 | 
			
		||||
    implements(IConcept, IConceptManagerContained)
 | 
			
		||||
 | 
			
		||||
    _title = u''
 | 
			
		||||
    def getTitle(self): return self._title
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +60,7 @@ class Concept(Persistent, Contained):
 | 
			
		|||
        rels = getRelations(second=self, relationships=relationships)
 | 
			
		||||
        return [r.first for r in rels]
 | 
			
		||||
 | 
			
		||||
    def assignConcept(self, concept, relationship):
 | 
			
		||||
    def assignConcept(self, concept, relationship=ConceptRelation):
 | 
			
		||||
        registry = zapi.getUtility(IRelationsRegistry)
 | 
			
		||||
        registry.register(relationship(self, concept))
 | 
			
		||||
        # TODO (?): avoid duplicates
 | 
			
		||||
| 
						 | 
				
			
			@ -65,7 +69,12 @@ class Concept(Persistent, Contained):
 | 
			
		|||
        pass  # TODO
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# TODO: move this to the relation package
 | 
			
		||||
class ConceptManager(BTreeContainer):
 | 
			
		||||
 | 
			
		||||
    implements(IConceptManager, ILoopsContained)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# TODO: move this to the cybertools.relation package
 | 
			
		||||
 | 
			
		||||
def getRelations(first=None, second=None, third=None, relationships=None):
 | 
			
		||||
    registry = zapi.getUtility(IRelationsRegistry)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,51 @@
 | 
			
		|||
 | 
			
		||||
  <!-- Security definitions -->
 | 
			
		||||
 | 
			
		||||
  <!-- Content declarations -->
 | 
			
		||||
  <!-- loops top-level container -->
 | 
			
		||||
 | 
			
		||||
  <interface interface=".interfaces.ILoops"
 | 
			
		||||
             type="zope.app.content.interfaces.IContentType" />
 | 
			
		||||
 | 
			
		||||
  <content class=".Loops">
 | 
			
		||||
 | 
			
		||||
    <implements
 | 
			
		||||
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 | 
			
		||||
 | 
			
		||||
    <factory id="loops.Loops"
 | 
			
		||||
             description="loops top-level container" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.View"
 | 
			
		||||
        interface="zope.app.container.interfaces.IReadContainer" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.ManageContent"
 | 
			
		||||
        interface="zope.app.container.interfaces.IWriteContainer" />
 | 
			
		||||
 | 
			
		||||
  </content>
 | 
			
		||||
 | 
			
		||||
  <!-- concept manager and concept -->
 | 
			
		||||
 | 
			
		||||
  <interface interface=".interfaces.IConceptManager"
 | 
			
		||||
             type="zope.app.content.interfaces.IContentType" />
 | 
			
		||||
 | 
			
		||||
  <content class=".concept.ConceptManager">
 | 
			
		||||
 | 
			
		||||
    <implements
 | 
			
		||||
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 | 
			
		||||
 | 
			
		||||
    <factory id="loops.ConceptManager"
 | 
			
		||||
             description="Concept manager" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.View"
 | 
			
		||||
        interface="zope.app.container.interfaces.IReadContainer" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.ManageContent"
 | 
			
		||||
        interface="zope.app.container.interfaces.IWriteContainer" />
 | 
			
		||||
 | 
			
		||||
  </content>
 | 
			
		||||
 | 
			
		||||
  <interface
 | 
			
		||||
      interface=".interfaces.IConcept"
 | 
			
		||||
| 
						 | 
				
			
			@ -15,8 +59,6 @@
 | 
			
		|||
 | 
			
		||||
  <content class=".concept.Concept">
 | 
			
		||||
 | 
			
		||||
    <implements interface="zope.app.container.interfaces.IContentContainer" />
 | 
			
		||||
 | 
			
		||||
    <implements
 | 
			
		||||
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -24,10 +66,6 @@
 | 
			
		|||
        id="loops.Concept"
 | 
			
		||||
        description="Concept object" />
 | 
			
		||||
 | 
			
		||||
    <!-- <require
 | 
			
		||||
        permission="zope.View"
 | 
			
		||||
        interface="zope.app.container.interfaces.IReadContainer"/> -->
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.View"
 | 
			
		||||
        interface=".interfaces.IConcept" />
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +76,52 @@
 | 
			
		|||
 | 
			
		||||
  </content>
 | 
			
		||||
 | 
			
		||||
  <!-- resource manager and resource -->
 | 
			
		||||
 | 
			
		||||
  <interface interface=".interfaces.IResourceManager"
 | 
			
		||||
             type="zope.app.content.interfaces.IContentType" />
 | 
			
		||||
 | 
			
		||||
  <content class=".resource.ResourceManager">
 | 
			
		||||
 | 
			
		||||
    <implements
 | 
			
		||||
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 | 
			
		||||
 | 
			
		||||
    <factory id="loops.ResourceManager"
 | 
			
		||||
             description="Resource manager" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.View"
 | 
			
		||||
        interface="zope.app.container.interfaces.IReadContainer" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.ManageContent"
 | 
			
		||||
        interface="zope.app.container.interfaces.IWriteContainer" />
 | 
			
		||||
 | 
			
		||||
  </content>
 | 
			
		||||
 | 
			
		||||
  <interface
 | 
			
		||||
      interface=".interfaces.IDocument"
 | 
			
		||||
      type="zope.app.content.interfaces.IContentType" />
 | 
			
		||||
 | 
			
		||||
  <content class=".resource.Document">
 | 
			
		||||
 | 
			
		||||
    <implements
 | 
			
		||||
       interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 | 
			
		||||
 | 
			
		||||
    <factory
 | 
			
		||||
        id="loops.Document"
 | 
			
		||||
        description="Document" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.View"
 | 
			
		||||
        interface=".interfaces.IDocument" />
 | 
			
		||||
 | 
			
		||||
    <require
 | 
			
		||||
        permission="zope.ManageContent"
 | 
			
		||||
        set_schema=".interfaces.IDocument" />
 | 
			
		||||
 | 
			
		||||
  </content>
 | 
			
		||||
 | 
			
		||||
  <!-- Register various browser related components, including all views -->
 | 
			
		||||
  <include package=".browser" />
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										128
									
								
								interfaces.py
									
										
									
									
									
								
							
							
						
						
									
										128
									
								
								interfaces.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -25,20 +25,28 @@ $Id$
 | 
			
		|||
from zope.interface import Interface
 | 
			
		||||
from zope.i18nmessageid import MessageFactory
 | 
			
		||||
from zope import schema
 | 
			
		||||
from zope.app.container.constraints import contains, containers
 | 
			
		||||
from zope.app.container.interfaces import IContainer
 | 
			
		||||
from zope.app.file.interfaces import IFile as IBaseFile
 | 
			
		||||
from zope.app.folder.interfaces import IFolder
 | 
			
		||||
 | 
			
		||||
_ = MessageFactory('loops')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# concept interfaces
 | 
			
		||||
 | 
			
		||||
class IConcept(Interface):
 | 
			
		||||
    """ The 'concept' is the central element of the loops framework.
 | 
			
		||||
        A concept is related to other concepts.
 | 
			
		||||
    """ The concept is the central element of the loops framework.
 | 
			
		||||
    
 | 
			
		||||
        A concept is related to other concepts, may have resources
 | 
			
		||||
        associated with it and may be referenced by views.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    title = schema.TextLine(
 | 
			
		||||
        title=_(u'Title'),
 | 
			
		||||
        description=_(u'Name or short title of the concept'),
 | 
			
		||||
        description=_(u'Title of the concept'),
 | 
			
		||||
        default=u'',
 | 
			
		||||
        required=True)
 | 
			
		||||
        required=False)
 | 
			
		||||
 | 
			
		||||
    def getSubConcepts(relationships=None):
 | 
			
		||||
        """ Return a tuple of concepts related to self as sub-concepts,
 | 
			
		||||
| 
						 | 
				
			
			@ -62,3 +70,115 @@ class IConcept(Interface):
 | 
			
		|||
            restricting them to the relationships given.
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
class IConceptManager(IContainer):
 | 
			
		||||
    """ A manager/container for concepts.
 | 
			
		||||
    """
 | 
			
		||||
    contains(IConcept)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IConceptManagerContained(Interface):
 | 
			
		||||
    containers(IConceptManager)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# resource interfaces
 | 
			
		||||
 | 
			
		||||
class IResource(Interface):
 | 
			
		||||
    """ A resource is an atomic information element that is usually
 | 
			
		||||
        available via a concept.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    title = schema.TextLine(
 | 
			
		||||
                title=_(u'Title'),
 | 
			
		||||
                description=_(u'Title of the document'),
 | 
			
		||||
                required=False)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IDocument(IResource):
 | 
			
		||||
    """ A resource containing an editable body.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    body = schema.Text(
 | 
			
		||||
                title=_(u'Body'),
 | 
			
		||||
                description=_(u'Body of the document'),
 | 
			
		||||
                required=False)
 | 
			
		||||
 | 
			
		||||
    format = schema.TextLine(
 | 
			
		||||
                title=_(u'Format'),
 | 
			
		||||
                description=_(u'Format of the body field, default is "text/xml"'),
 | 
			
		||||
                default=_(u'text/xml'),
 | 
			
		||||
                required=False)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IFile(IResource, IBaseFile):
 | 
			
		||||
    """ A resource containing a (typically binary) file-like content
 | 
			
		||||
        or an image.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IResourceManager(IContainer):
 | 
			
		||||
    """ A manager/container for resources.
 | 
			
		||||
    """
 | 
			
		||||
    contains(IResource)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IResourceManagerContained(Interface):
 | 
			
		||||
    containers(IResourceManager)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# view interfaces
 | 
			
		||||
 | 
			
		||||
class IView(Interface):
 | 
			
		||||
    """ A view is a user interface component that provides access to one
 | 
			
		||||
        or more concepts.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    title = schema.TextLine(
 | 
			
		||||
        title=_(u'Title'),
 | 
			
		||||
        description=_(u'Title of the view; this will appear e.g. in menus'),
 | 
			
		||||
        default=u'',
 | 
			
		||||
        required=True)
 | 
			
		||||
 | 
			
		||||
    description = schema.Text(
 | 
			
		||||
        title=_(u'Description'),
 | 
			
		||||
        description=_(u'Detailed description, e.g. for tooltips or listings'),
 | 
			
		||||
        default=u'',
 | 
			
		||||
        required=False)
 | 
			
		||||
 | 
			
		||||
    def getConcepts():
 | 
			
		||||
        """ Return an ordered sequence of concepts referenced by this view.
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class INode(IContainer):
 | 
			
		||||
    """ A node is a view that may contain other views, thus building a
 | 
			
		||||
        menu or folder hierarchy.
 | 
			
		||||
    """
 | 
			
		||||
    contains(IView)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IViewManager(IContainer):
 | 
			
		||||
    """ A manager/container for views.
 | 
			
		||||
    """
 | 
			
		||||
    contains(IView)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class INodeContained(Interface):
 | 
			
		||||
    containers(INode, IViewManager)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class IViewManagerContained(Interface):
 | 
			
		||||
    containers(IViewManager)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# the loops top-level container
 | 
			
		||||
 | 
			
		||||
class ILoops(IFolder):
 | 
			
		||||
    """ The top-level object of a loops site.
 | 
			
		||||
    """
 | 
			
		||||
    contains(IConceptManager, IResourceManager, IViewManager)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
class ILoopsContained(Interface):
 | 
			
		||||
    containers(ILoops)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										44
									
								
								relations.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								relations.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,44 @@
 | 
			
		|||
#
 | 
			
		||||
#  Copyright (c) 2005 Helmut Merz helmutm@cy55.de
 | 
			
		||||
#
 | 
			
		||||
#  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#  it under the terms of the GNU General Public License as published by
 | 
			
		||||
#  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#  (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#  This program is distributed in the hope that it will be useful,
 | 
			
		||||
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#  GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#  You should have received a copy of the GNU General Public License
 | 
			
		||||
#  along with this program; if not, write to the Free Software
 | 
			
		||||
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
Definition of relation classes.
 | 
			
		||||
 | 
			
		||||
$Id$
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from zope.app import zapi
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
 | 
			
		||||
from cybertools.relation import DyadicRelation
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ConceptRelation(DyadicRelation):
 | 
			
		||||
    """ A relation between concept objects.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ResourceRelation(DyadicRelation):
 | 
			
		||||
    """ A relation between concept and resource objects.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ViewRelation(DyadicRelation):
 | 
			
		||||
    """ A relation between view and concept objects.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										68
									
								
								resource.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								resource.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,68 @@
 | 
			
		|||
#
 | 
			
		||||
#  Copyright (c) 2005 Helmut Merz helmutm@cy55.de
 | 
			
		||||
#
 | 
			
		||||
#  This program is free software; you can redistribute it and/or modify
 | 
			
		||||
#  it under the terms of the GNU General Public License as published by
 | 
			
		||||
#  the Free Software Foundation; either version 2 of the License, or
 | 
			
		||||
#  (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
#  This program is distributed in the hope that it will be useful,
 | 
			
		||||
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
#  GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
#  You should have received a copy of the GNU General Public License
 | 
			
		||||
#  along with this program; if not, write to the Free Software
 | 
			
		||||
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
"""
 | 
			
		||||
Definition of the Concept class.
 | 
			
		||||
 | 
			
		||||
$Id$
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
from zope.app import zapi
 | 
			
		||||
from zope.app.container.btree import BTreeContainer
 | 
			
		||||
from zope.app.container.contained import Contained
 | 
			
		||||
from zope.interface import implements
 | 
			
		||||
from persistent import Persistent
 | 
			
		||||
 | 
			
		||||
from interfaces import IResource, IDocument
 | 
			
		||||
from interfaces import IResourceManager, IResourceManagerContained
 | 
			
		||||
from interfaces import ILoopsContained
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Resource(Contained, Persistent):
 | 
			
		||||
 | 
			
		||||
    implements(IResource, IResourceManagerContained)
 | 
			
		||||
 | 
			
		||||
    _title = u''
 | 
			
		||||
    def getTitle(self): return self._title
 | 
			
		||||
    def setTitle(self, title): self._title = title
 | 
			
		||||
    title = property(getTitle, setTitle)
 | 
			
		||||
 | 
			
		||||
    def __init__(self, name=None, title=u''):
 | 
			
		||||
        self.title = title
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Document(Resource):
 | 
			
		||||
 | 
			
		||||
    implements(IDocument)
 | 
			
		||||
        
 | 
			
		||||
    _body = u''
 | 
			
		||||
    def setBody(self, body): self._body = body
 | 
			
		||||
    def getBody(self): return self._body
 | 
			
		||||
    body = property(getBody, setBody)
 | 
			
		||||
 | 
			
		||||
    _format = u'text/xml'
 | 
			
		||||
    def setFormat(self, format): self._format = format
 | 
			
		||||
    def getFormat(self): return self._format
 | 
			
		||||
    format = property(getFormat, setFormat)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ResourceManager(BTreeContainer):
 | 
			
		||||
 | 
			
		||||
    implements(IResourceManager, ILoopsContained)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								tests.py
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								tests.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -8,15 +8,21 @@ from zope.interface import implements
 | 
			
		|||
from zope.app import zapi
 | 
			
		||||
from zope.app.intid.interfaces import IIntIds
 | 
			
		||||
 | 
			
		||||
from interfaces import IConcept
 | 
			
		||||
from concept import Concept
 | 
			
		||||
from interfaces import ILoops
 | 
			
		||||
from loops import Loops
 | 
			
		||||
from interfaces import IConcept, IConceptManager
 | 
			
		||||
from loops.concept import Concept, ConceptManager
 | 
			
		||||
 | 
			
		||||
class Test(unittest.TestCase):
 | 
			
		||||
    "Basic tests for the loops package."
 | 
			
		||||
 | 
			
		||||
    def testInterfaces(self):
 | 
			
		||||
        verifyClass(ILoops, Loops)
 | 
			
		||||
        self.assert_(ILoops.providedBy(Loops()))
 | 
			
		||||
        verifyClass(IConcept, Concept)
 | 
			
		||||
        self.assert_(IConcept.providedBy(Concept()))
 | 
			
		||||
        verifyClass(IConceptManager, ConceptManager)
 | 
			
		||||
        self.assert_(IConceptManager.providedBy(ConceptManager()))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_suite():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue