work in progress: make the loops framework practically usable
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1121 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									1adedb7b0e
								
							
						
					
					
						commit
						628e81b740
					
				
					 7 changed files with 204 additions and 7 deletions
				
			
		|  | @ -30,6 +30,8 @@ from zope.app.form.browser.interfaces import ITerms | ||||||
| from zope.cachedescriptors.property import Lazy | from zope.cachedescriptors.property import Lazy | ||||||
| from zope.dottedname.resolve import resolve | from zope.dottedname.resolve import resolve | ||||||
| from zope.event import notify | from zope.event import notify | ||||||
|  | from zope.formlib.form import EditForm, FormFields | ||||||
|  | from zope.formlib.namedtemplate import NamedTemplate | ||||||
| from zope.interface import implements | from zope.interface import implements | ||||||
| from zope.publisher.interfaces import BadRequest | from zope.publisher.interfaces import BadRequest | ||||||
| from zope.publisher.interfaces.browser import IBrowserRequest | from zope.publisher.interfaces.browser import IBrowserRequest | ||||||
|  | @ -44,6 +46,12 @@ from loops.browser.common import BaseView, LoopsTerms | ||||||
| from loops import util | from loops import util | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | class ConceptEditForm(EditForm): | ||||||
|  | 
 | ||||||
|  |     form_fields = FormFields(IConcept) | ||||||
|  |     template = NamedTemplate('pageform') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| class ConceptView(BaseView): | class ConceptView(BaseView): | ||||||
| 
 | 
 | ||||||
|     def children(self): |     def children(self): | ||||||
|  |  | ||||||
|  | @ -109,7 +109,7 @@ | ||||||
|       permission="zope.ManageContent"> |       permission="zope.ManageContent"> | ||||||
|      |      | ||||||
|     <page |     <page | ||||||
|         name="related.html" |         name="configure.html" | ||||||
|         template="concept_related.pt" |         template="concept_related.pt" | ||||||
|         menu="zmi_views" title="Related Concepts" |         menu="zmi_views" title="Related Concepts" | ||||||
|         /> |         /> | ||||||
|  | @ -122,13 +122,26 @@ | ||||||
|      |      | ||||||
|   </pages> |   </pages> | ||||||
|      |      | ||||||
|   <editform |   <!--<editform | ||||||
|       label="Edit Concept" |       label="Edit Concept" | ||||||
|       name="edit.html" |       name="edit.html" | ||||||
|       schema="loops.interfaces.IConcept" |       schema="loops.interfaces.IConcept" | ||||||
|       for="loops.interfaces.IConcept" |       for="loops.interfaces.IConcept" | ||||||
|       permission="zope.ManageContent" |       permission="zope.ManageContent" | ||||||
|       menu="zmi_views" title="Edit" |       menu="zmi_views" title="Edit" | ||||||
|  |       />--> | ||||||
|  | 
 | ||||||
|  |   <zope:adapter | ||||||
|  |       factory="loops.browser.util.pageform" | ||||||
|  |       for="zope.interface.Interface" | ||||||
|  |       name="pageform" /> | ||||||
|  | 
 | ||||||
|  |   <page | ||||||
|  |       name="edit.html" | ||||||
|  |       for="loops.interfaces.IConcept" | ||||||
|  |       class="loops.browser.concept.ConceptEditForm" | ||||||
|  |       permission="zope.ManageContent" | ||||||
|  |       menu="zmi_views" title="Edit" | ||||||
|       /> |       /> | ||||||
| 
 | 
 | ||||||
|   <page |   <page | ||||||
|  | @ -179,7 +192,7 @@ | ||||||
|     <page |     <page | ||||||
|         name="configure.html" |         name="configure.html" | ||||||
|         template="resource_configure.pt" |         template="resource_configure.pt" | ||||||
|         menu="zmi_views" title="Concepts" |         menu="zmi_views" title="Configure" | ||||||
|         /> |         /> | ||||||
|      |      | ||||||
|   </pages> |   </pages> | ||||||
|  | @ -319,7 +332,6 @@ | ||||||
|       content_factory="loops.view.Node" |       content_factory="loops.view.Node" | ||||||
|       schema="loops.interfaces.INode" |       schema="loops.interfaces.INode" | ||||||
|       fields="title description nodeType body" |       fields="title description nodeType body" | ||||||
|       class="loops.browser.node.ConfigureView" |  | ||||||
|       permission="zope.ManageContent"> |       permission="zope.ManageContent"> | ||||||
|        |        | ||||||
|     <widget field="description" height="2" /> |     <widget field="description" height="2" /> | ||||||
|  |  | ||||||
|  | @ -118,7 +118,7 @@ class NodeView(object): | ||||||
|         if target is None or IDocument.providedBy(target): |         if target is None or IDocument.providedBy(target): | ||||||
|             return 'textbody' |             return 'textbody' | ||||||
|         if IConcept.providedBy(target): # TODO... |         if IConcept.providedBy(target): # TODO... | ||||||
|             return 'filebody' |             return 'conceptbody' | ||||||
|         if IMediaAsset.providedBy(target) and target.contentType.startswith('image/'): |         if IMediaAsset.providedBy(target) and target.contentType.startswith('image/'): | ||||||
|             return 'imagebody' |             return 'imagebody' | ||||||
|         return 'filebody' |         return 'filebody' | ||||||
|  |  | ||||||
|  | @ -12,10 +12,10 @@ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| <metal:body define-macro="textbody"> | <metal:body define-macro="textbody"> | ||||||
|   <tal:body define="body item/body" |   <tal:body define="body item/body"> | ||||||
|             condition="body"> |  | ||||||
|           <div class="content-1" |           <div class="content-1" | ||||||
|                tal:define="onclick string:openEditWindow('${item/url}/@@edit.html')" |                tal:define="onclick string:openEditWindow('${item/url}/@@edit.html')" | ||||||
|  |                tal:condition="body" | ||||||
|                tal:attributes="class string:content-$level; |                tal:attributes="class string:content-$level; | ||||||
|                                ondblclick python: item.editable and onclick or ''" |                                ondblclick python: item.editable and onclick or ''" | ||||||
|                tal:content="structure body"> |                tal:content="structure body"> | ||||||
|  | @ -34,6 +34,21 @@ | ||||||
| </metal:body> | </metal:body> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | <metal:body define-macro="conceptbody"> | ||||||
|  |   <tal:body define="body item/body"> | ||||||
|  |     <div class="content-1" | ||||||
|  |          tal:define="onclick string:openEditWindow('${item/url}/@@configure.html')" | ||||||
|  |          tal:attributes="class string:content-$level; | ||||||
|  |                          ondblclick python: item.editable and onclick or ''"> | ||||||
|  |       <a href="#" | ||||||
|  |          tal:omit-tag="" | ||||||
|  |          tal:attributes="href item/target/@@absolute_url" | ||||||
|  |          tal:content="structure body">The body</a> | ||||||
|  |     </div> | ||||||
|  |   </tal:body> | ||||||
|  | </metal:body> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| <metal:body define-macro="filebody"> | <metal:body define-macro="filebody"> | ||||||
|   <tal:body define="body item/body"> |   <tal:body define="body item/body"> | ||||||
|     <div class="content-1" |     <div class="content-1" | ||||||
|  |  | ||||||
							
								
								
									
										153
									
								
								browser/pageform.pt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								browser/pageform.pt
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,153 @@ | ||||||
|  | <html metal:extend-macro="context/@@standard_macros/view" | ||||||
|  |       metal:define-macro="main"> | ||||||
|  | <head> | ||||||
|  | </head> | ||||||
|  | 
 | ||||||
|  | <body> | ||||||
|  | <div metal:fill-slot="body"> | ||||||
|  | 
 | ||||||
|  | <div metal:define-macro="form"> | ||||||
|  | 
 | ||||||
|  | <form action="." metal:define-macro="master" | ||||||
|  |       tal:attributes="action request/URL" method="post" | ||||||
|  |       class="edit-form" enctype="multipart/form-data" | ||||||
|  |       id="zc.page.browser_form"> | ||||||
|  | 
 | ||||||
|  | <script type="text/javascript"><!-- | ||||||
|  | 
 | ||||||
|  | function toggleFormFieldHelp(ob,state) { | ||||||
|  |   // ob is the label element | ||||||
|  |   var field = ob.form[ob.htmlFor]; | ||||||
|  |   if (field) { | ||||||
|  |     var viz = state && 'hidden' || 'visible'; | ||||||
|  |     if (field.length == null) { | ||||||
|  |       field.style.visibility = viz; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |       for (var i = 0; i < field.length; ++i) { | ||||||
|  |         var e = field.item(i); | ||||||
|  |         e.style.visibility = viz; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     var help = document.getElementById("field-help-for-" + field.name); | ||||||
|  |     if (help) { | ||||||
|  |       help.style.visibility = state && 'visible' || 'hidden'; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | //--> | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <div id="viewspace" metal:define-slot="viewspace"> | ||||||
|  | 
 | ||||||
|  |   <h1  i18n:translate="heading_editform" | ||||||
|  |        metal:define-slot="heading">Edit | ||||||
|  |     <span i18n:name="title" | ||||||
|  |           tal:content="context/title">Concept</span> | ||||||
|  |   </h1> | ||||||
|  | 
 | ||||||
|  |   <metal:block define-macro="header"> | ||||||
|  | 
 | ||||||
|  |     <div class="form-status" | ||||||
|  |        tal:define="status view/status" | ||||||
|  |        tal:condition="status"> | ||||||
|  | 
 | ||||||
|  |       <div class="summary" | ||||||
|  |            i18n:translate="" | ||||||
|  |            tal:content="view/status"> | ||||||
|  |         Form status summary | ||||||
|  |       </div> | ||||||
|  | 
 | ||||||
|  |       <ul class="errors" tal:condition="view/errors"> | ||||||
|  |          <li tal:repeat="error view/error_views"> | ||||||
|  |             <span tal:replace="structure error">Error Type</span> | ||||||
|  |          </li> | ||||||
|  |       </ul> | ||||||
|  |     </div> | ||||||
|  | 
 | ||||||
|  |   <br /> | ||||||
|  |   </metal:block> | ||||||
|  | 
 | ||||||
|  |   <div metal:define-slot="extra_info" tal:replace="nothing"> | ||||||
|  |   </div> | ||||||
|  | 
 | ||||||
|  |   <table class="form-fields"> | ||||||
|  |     <tr class="row" metal:define-slot="extra_top" tal:replace="nothing"> | ||||||
|  |         <td class="label">Extra top</td> | ||||||
|  |         <td class="label"><input type="text" /></td> | ||||||
|  |     </tr> | ||||||
|  |     <tbody metal:define-slot="formbody" tal:omit-tag=""> | ||||||
|  |       <tr tal:repeat="widget view/widgets"> | ||||||
|  |         <td class="label" tal:define="hint widget/hint" | ||||||
|  |           metal:define-macro="labelcell"> | ||||||
|  |           <label tal:condition="python:hint" | ||||||
|  |                  tal:attributes="for widget/name" | ||||||
|  |                  onmousedown="toggleFormFieldHelp(this,1)" | ||||||
|  |                  onmouseup="toggleFormFieldHelp(this,0)" | ||||||
|  |                  onmouseout="toggleFormFieldHelp(this,0)" | ||||||
|  |                  style="cursor: help"> | ||||||
|  |             <span class="required" tal:condition="widget/required" | ||||||
|  |             >*</span><span i18n:translate="" | ||||||
|  |                            tal:content="widget/label">label</span> | ||||||
|  |           </label> | ||||||
|  |           <label tal:condition="python:not hint" | ||||||
|  |                  tal:attributes="for widget/name"> | ||||||
|  |             <span class="required" tal:condition="widget/required" | ||||||
|  |             >*</span><span i18n:translate="" | ||||||
|  |                            tal:content="widget/label">label</span> | ||||||
|  |           </label> | ||||||
|  |         </td> | ||||||
|  |         <td class="field" tal:define="hint widget/hint" | ||||||
|  |             metal:define-macro="widgetcell"> | ||||||
|  |           <div class="form-fields-help" | ||||||
|  |                i18n:translate="" | ||||||
|  |                tal:content="hint" | ||||||
|  |                tal:condition="hint" | ||||||
|  |                tal:attributes="id string:field-help-for-${widget/name}" | ||||||
|  |                onclick="this.style.visibility='hidden';" | ||||||
|  |                style="visibility: hidden; position: absolute;" | ||||||
|  |                >Title of this content object.</div> | ||||||
|  |           <div class="widget" tal:content="structure widget"> | ||||||
|  |           <input type="text" /></div> | ||||||
|  |           <div class="error" | ||||||
|  |                tal:condition="widget/error" | ||||||
|  |                > | ||||||
|  |             <!-- TODO Put this back, the Zope3 way. | ||||||
|  |             <img src="alert.gif" alt="Error" | ||||||
|  |             tal:replace="structure context/alert.gif" /> | ||||||
|  |             --> | ||||||
|  |             <span tal:replace="structure widget/error">error</span> | ||||||
|  |           </div> | ||||||
|  |         </td> | ||||||
|  |       </tr> | ||||||
|  |     </tbody> | ||||||
|  |     <tr class="row" metal:define-slot="extra_bottom" tal:replace="nothing"> | ||||||
|  |       <td class="label">Extra bottom</td> | ||||||
|  |       <td class="label"><input type="text" /></td> | ||||||
|  |     </tr> | ||||||
|  |   </table> | ||||||
|  |   <metal:block define-slot="above_buttons" /> | ||||||
|  | </div> | ||||||
|  | <div id="actionsView"> | ||||||
|  |   <br /> | ||||||
|  |   <span class="actionButtons" | ||||||
|  |         tal:condition="view/availableActions" | ||||||
|  |         metal:define-slot="bottom_buttons"> | ||||||
|  |     <input tal:repeat="action view/actions" | ||||||
|  |            tal:replace="structure action/render" | ||||||
|  |            /> | ||||||
|  |   </span> | ||||||
|  | </div> | ||||||
|  | 
 | ||||||
|  | </form> | ||||||
|  | <script type="text/javascript" metal:define-slot="trackChanges"> | ||||||
|  |   zc_trackChanges(document.getElementById('zc.page.browser_form')); | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <script type="text/javascript" | ||||||
|  |     tal:define="extra_script view/extra_script | nothing" | ||||||
|  |     tal:condition="extra_script" | ||||||
|  |     tal:content="structure extra_script" /> | ||||||
|  | 
 | ||||||
|  | </div></div></body></html> | ||||||
|  | @ -23,8 +23,13 @@ $Id$ | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| from zope.app import zapi | from zope.app import zapi | ||||||
|  | from zope.app.pagetemplate import ViewPageTemplateFile | ||||||
| from zope.app.publisher.browser.menu import BrowserMenu | from zope.app.publisher.browser.menu import BrowserMenu | ||||||
| from zope.app.publisher.interfaces.browser import IBrowserSubMenuItem | from zope.app.publisher.interfaces.browser import IBrowserSubMenuItem | ||||||
|  | from zope.formlib.namedtemplate import NamedTemplateImplementation | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | pageform = NamedTemplateImplementation(ViewPageTemplateFile('pageform.pt')) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class LoopsMenu(BrowserMenu): | class LoopsMenu(BrowserMenu): | ||||||
|  |  | ||||||
|  | @ -107,6 +107,8 @@ So let's check the type of the type object: | ||||||
|   '.loops/concepts/type' |   '.loops/concepts/type' | ||||||
|   >>> type_type.tokenForSearch |   >>> type_type.tokenForSearch | ||||||
|   'loops:concept:type' |   'loops:concept:type' | ||||||
|  |   >>> type_type.qualifiers | ||||||
|  |   ('concept', 'system',) | ||||||
| 
 | 
 | ||||||
| Now we register another type ('topic') and assign it to cc1: | Now we register another type ('topic') and assign it to cc1: | ||||||
| 
 | 
 | ||||||
|  | @ -126,6 +128,8 @@ lazy properties, one should always get a new adapter: | ||||||
|   False |   False | ||||||
|   >>> cc1_type.typeProvider == topic |   >>> cc1_type.typeProvider == topic | ||||||
|   True |   True | ||||||
|  |   >>> topic_type.qualifiers | ||||||
|  |   ('concept',) | ||||||
| 
 | 
 | ||||||
| Now let's have a look at resources. | Now let's have a look at resources. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm