Basic interfaces and classes set up and running
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@815 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									a659d8c7de
								
							
						
					
					
						commit
						b9dfa307d1
					
				
					 5 changed files with 192 additions and 3 deletions
				
			
		|  | @ -139,8 +139,8 @@ | ||||||
|       label="Add Document" |       label="Add Document" | ||||||
|       name="AddLoopsDocument.html" |       name="AddLoopsDocument.html" | ||||||
|       schema="loops.interfaces.IDocument" |       schema="loops.interfaces.IDocument" | ||||||
|       content_factory="loops.resource.Document" |  | ||||||
|       fields="title body format" |       fields="title body format" | ||||||
|  |       content_factory="loops.resource.Document" | ||||||
|       permission="zope.ManageContent" |       permission="zope.ManageContent" | ||||||
|       /> |       /> | ||||||
| 
 | 
 | ||||||
|  | @ -156,9 +156,69 @@ | ||||||
|       label="Edit Document" |       label="Edit Document" | ||||||
|       name="edit.html" |       name="edit.html" | ||||||
|       schema="loops.interfaces.IDocument" |       schema="loops.interfaces.IDocument" | ||||||
|  |       fields="title body format" | ||||||
|       for="loops.interfaces.IDocument" |       for="loops.interfaces.IDocument" | ||||||
|       permission="zope.ManageContent" |       permission="zope.ManageContent" | ||||||
|       menu="zmi_views" title="Edit" |       menu="zmi_views" title="Edit" | ||||||
|       /> |       /> | ||||||
| 
 | 
 | ||||||
|  |   <!-- view manager --> | ||||||
|  | 
 | ||||||
|  |   <addform | ||||||
|  |       label="Add View Manager" | ||||||
|  |       name="AddLoopsViewManager.html" | ||||||
|  |       schema="loops.interfaces.IViewManager" | ||||||
|  |       content_factory="loops.view.ViewManager" | ||||||
|  |       permission="zope.ManageContent" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
|  |   <addMenuItem | ||||||
|  |       class="loops.view.ViewManager" | ||||||
|  |       title="View Manager" | ||||||
|  |       description="A view manager manages views, like nodes, menu items, ..." | ||||||
|  |       permission="zope.ManageContent" | ||||||
|  |       view="AddLoopsViewManager.html" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
|  |   <containerViews | ||||||
|  |       for="loops.interfaces.IViewManager" | ||||||
|  |       contents="zope.View" | ||||||
|  |       add="zope.ManageContent" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
|  |   <!-- node --> | ||||||
|  | 
 | ||||||
|  |   <containerViews | ||||||
|  |       for="loops.interfaces.INode" | ||||||
|  |       contents="zope.View" | ||||||
|  |       add="zope.ManageContent" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
|  |   <addform | ||||||
|  |       label="Add Node" | ||||||
|  |       name="AddLoopsNode.html" | ||||||
|  |       content_factory="loops.view.Node" | ||||||
|  |       schema="loops.interfaces.INode" | ||||||
|  |       fields="title description" | ||||||
|  |       permission="zope.ManageContent" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
|  |   <addMenuItem | ||||||
|  |       class="loops.view.Node" | ||||||
|  |       title="Node" | ||||||
|  |       description="A node provides access to concepts, possibly hierarchically organized" | ||||||
|  |       permission="zope.ManageContent" | ||||||
|  |       view="AddLoopsNode.html" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
|  |   <editform | ||||||
|  |       label="Edit Node" | ||||||
|  |       name="edit.html" | ||||||
|  |       schema="loops.interfaces.INode" | ||||||
|  |       fields="title description" | ||||||
|  |       for="loops.interfaces.INode" | ||||||
|  |       permission="zope.ManageContent" | ||||||
|  |       menu="zmi_views" title="Edit" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
| </configure> | </configure> | ||||||
|  |  | ||||||
|  | @ -122,6 +122,56 @@ | ||||||
| 
 | 
 | ||||||
|   </content> |   </content> | ||||||
| 
 | 
 | ||||||
|  |   <!-- view manager and view --> | ||||||
|  | 
 | ||||||
|  |   <interface interface=".interfaces.IViewManager" | ||||||
|  |              type="zope.app.content.interfaces.IContentType" /> | ||||||
|  | 
 | ||||||
|  |   <content class=".view.ViewManager"> | ||||||
|  | 
 | ||||||
|  |     <implements | ||||||
|  |        interface="zope.app.annotation.interfaces.IAttributeAnnotatable" /> | ||||||
|  | 
 | ||||||
|  |     <factory id="loops.ViewManager" | ||||||
|  |              description="View 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.INode" | ||||||
|  |       type="zope.app.content.interfaces.IContentType" /> | ||||||
|  | 
 | ||||||
|  |   <content class=".view.Node"> | ||||||
|  | 
 | ||||||
|  |     <implements | ||||||
|  |        interface="zope.app.annotation.interfaces.IAttributeAnnotatable" /> | ||||||
|  | 
 | ||||||
|  |     <factory | ||||||
|  |         id="loops.Node" | ||||||
|  |         description="Node" /> | ||||||
|  | 
 | ||||||
|  |     <require | ||||||
|  |         permission="zope.View" | ||||||
|  |         interface=".interfaces.INode" /> | ||||||
|  | 
 | ||||||
|  |     <require | ||||||
|  |         permission="zope.ManageContent" | ||||||
|  |         set_schema=".interfaces.INode" /> | ||||||
|  | 
 | ||||||
|  |     <require | ||||||
|  |         permission="zope.View" | ||||||
|  |         interface="zope.app.container.interfaces.IReadContainer" /> | ||||||
|  | 
 | ||||||
|  |   </content> | ||||||
|  | 
 | ||||||
|   <!-- Register various browser related components, including all views --> |   <!-- Register various browser related components, including all views --> | ||||||
|   <include package=".browser" /> |   <include package=".browser" /> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -149,7 +149,7 @@ class IView(Interface): | ||||||
|         """ |         """ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class INode(IContainer): | class INode(IView): | ||||||
|     """ A node is a view that may contain other views, thus building a |     """ A node is a view that may contain other views, thus building a | ||||||
|         menu or folder hierarchy. |         menu or folder hierarchy. | ||||||
|     """ |     """ | ||||||
|  |  | ||||||
							
								
								
									
										13
									
								
								tests.py
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								tests.py
									
										
									
									
									
								
							|  | @ -10,8 +10,11 @@ from zope.app.intid.interfaces import IIntIds | ||||||
| 
 | 
 | ||||||
| from interfaces import ILoops | from interfaces import ILoops | ||||||
| from loops import Loops | from loops import Loops | ||||||
| from interfaces import IConcept, IConceptManager | from interfaces import IConcept, IConceptManager, IDocument, IResourceManager | ||||||
|  | from interfaces import INode, IViewManager | ||||||
| from loops.concept import Concept, ConceptManager | from loops.concept import Concept, ConceptManager | ||||||
|  | from loops.resource import Document, ResourceManager | ||||||
|  | from loops.view import Node, ViewManager | ||||||
| 
 | 
 | ||||||
| class Test(unittest.TestCase): | class Test(unittest.TestCase): | ||||||
|     "Basic tests for the loops package." |     "Basic tests for the loops package." | ||||||
|  | @ -23,6 +26,14 @@ class Test(unittest.TestCase): | ||||||
|         self.assert_(IConcept.providedBy(Concept())) |         self.assert_(IConcept.providedBy(Concept())) | ||||||
|         verifyClass(IConceptManager, ConceptManager) |         verifyClass(IConceptManager, ConceptManager) | ||||||
|         self.assert_(IConceptManager.providedBy(ConceptManager())) |         self.assert_(IConceptManager.providedBy(ConceptManager())) | ||||||
|  |         verifyClass(IDocument, Document) | ||||||
|  |         self.assert_(IDocument.providedBy(Document())) | ||||||
|  |         verifyClass(IResourceManager, ResourceManager) | ||||||
|  |         self.assert_(IResourceManager.providedBy(ResourceManager())) | ||||||
|  |         verifyClass(INode, Node) | ||||||
|  |         self.assert_(INode.providedBy(Node())) | ||||||
|  |         verifyClass(IViewManager, ViewManager) | ||||||
|  |         self.assert_(IViewManager.providedBy(ViewManager())) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_suite(): | def test_suite(): | ||||||
|  |  | ||||||
							
								
								
									
										68
									
								
								view.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								view.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 View and related classses. | ||||||
|  | 
 | ||||||
|  | $Id$ | ||||||
|  | """ | ||||||
|  | 
 | ||||||
|  | from zope.app import zapi | ||||||
|  | from zope.app.container.btree import BTreeContainer | ||||||
|  | from zope.app.container.contained import Contained | ||||||
|  | from zope.app.container.ordered import OrderedContainer | ||||||
|  | from zope.interface import implements | ||||||
|  | from persistent import Persistent | ||||||
|  | 
 | ||||||
|  | from interfaces import IView, INode | ||||||
|  | from interfaces import IViewManager, IViewManagerContained | ||||||
|  | from interfaces import ILoopsContained | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class View(object): | ||||||
|  | 
 | ||||||
|  |     implements(IView, IViewManagerContained) | ||||||
|  | 
 | ||||||
|  |     _title = u'' | ||||||
|  |     def getTitle(self): return self._title | ||||||
|  |     def setTitle(self, title): self._title = title | ||||||
|  |     title = property(getTitle, setTitle) | ||||||
|  | 
 | ||||||
|  |     _description = u'' | ||||||
|  |     def getDescription(self): return self._description | ||||||
|  |     def setDescription(self, description): self._description = description | ||||||
|  |     description = property(getDescription, setDescription) | ||||||
|  | 
 | ||||||
|  |     def __init__(self, name=None, title=u''): | ||||||
|  |         self.title = title | ||||||
|  |         self.description = description | ||||||
|  | 
 | ||||||
|  |     def getConcepts(self): | ||||||
|  |         return [] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Node(OrderedContainer, View): | ||||||
|  | 
 | ||||||
|  |     implements(INode) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class ViewManager(BTreeContainer): | ||||||
|  | 
 | ||||||
|  |     implements(IViewManager, ILoopsContained) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm