add first specialized view for external content access
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2772 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									905fd632b6
								
							
						
					
					
						commit
						208f5338ac
					
				
					 5 changed files with 44 additions and 4 deletions
				
			
		|  | @ -23,6 +23,7 @@ $Id$ | ||||||
| """ | """ | ||||||
| 
 | 
 | ||||||
| from zope import interface, component | from zope import interface, component | ||||||
|  | from zope.app.pagetemplate import ViewPageTemplateFile | ||||||
| from zope.app.publisher.browser import getDefaultViewName | from zope.app.publisher.browser import getDefaultViewName | ||||||
| from zope.cachedescriptors.property import Lazy | from zope.cachedescriptors.property import Lazy | ||||||
| 
 | 
 | ||||||
|  | @ -31,7 +32,10 @@ from loops.browser.node import NodeView | ||||||
| from loops.common import adapted | from loops.common import adapted | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ExternalAccessView(NodeView): | view_macros = ViewPageTemplateFile('view_macros.pt') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class ExternalAccessRenderer(NodeView): | ||||||
| 
 | 
 | ||||||
|     @Lazy |     @Lazy | ||||||
|     def adapted(self): |     def adapted(self): | ||||||
|  | @ -45,3 +49,14 @@ class ExternalAccessView(NodeView): | ||||||
| 
 | 
 | ||||||
|     def publishTraverse(self, request, name): |     def publishTraverse(self, request, name): | ||||||
|         return self.adapted()[name] |         return self.adapted()[name] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class FlashVideo(ConceptView): | ||||||
|  | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def macro(self): | ||||||
|  |         return view_macros.macros['flashvideo'] | ||||||
|  | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def startName(self): | ||||||
|  |         return self.adapted.address + '.html' | ||||||
|  |  | ||||||
|  | @ -40,11 +40,20 @@ | ||||||
|   <browser:page |   <browser:page | ||||||
|         name="xa" |         name="xa" | ||||||
|         for="loops.interfaces.INode" |         for="loops.interfaces.INode" | ||||||
|         class="loops.integrator.content.browser.ExternalAccessView" |         class="loops.integrator.content.browser.ExternalAccessRenderer" | ||||||
|         permission="zope.View" /> |         permission="zope.View" /> | ||||||
| 
 | 
 | ||||||
|   <browser:containerViews |   <browser:containerViews | ||||||
|         for="zope.app.container.interfaces.IReadContainer" |         for="zope.app.container.interfaces.IReadContainer" | ||||||
|         index="zope.View" /> |         index="zope.View" /> | ||||||
| 
 | 
 | ||||||
|  |   <zope:adapter | ||||||
|  |       name="flashvideo.html" | ||||||
|  |       for="loops.interfaces.IConcept | ||||||
|  |            zope.publisher.interfaces.browser.IBrowserRequest" | ||||||
|  |       provides="zope.interface.Interface" | ||||||
|  |       factory="loops.integrator.content.browser.FlashVideo" | ||||||
|  |       permission="zope.View" | ||||||
|  |       /> | ||||||
|  | 
 | ||||||
| </configure> | </configure> | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								integrator/content/view_macros.pt
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								integrator/content/view_macros.pt
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,16 @@ | ||||||
|  | <!-- ZPT macros for loops.integrator.content views | ||||||
|  |      $Id$ --> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | <div metal:define-macro="flashvideo"> | ||||||
|  |   <h1 tal:attributes="ondblclick item/openEditWindow"> | ||||||
|  |     <span tal:content="item/title">Title</span> | ||||||
|  |   </h1> | ||||||
|  |   <div><br /> | ||||||
|  |     <a href="." target="_blank" class="button" | ||||||
|  |        tal:define="baseUrl python: view.getUrlForTarget(item.context)" | ||||||
|  |        tal:attributes="href string:$baseUrl/xa/${item/startName}">Open Resource</a> | ||||||
|  |   </div> | ||||||
|  |   <metal:resources use-macro="item/conceptMacros/conceptchildren" /> | ||||||
|  |   <metal:resources use-macro="item/conceptMacros/conceptresources" /> | ||||||
|  | </div> | ||||||
|  | @ -57,7 +57,7 @@ class IExternalCollection(IConceptSchema): | ||||||
|             title=_(u'Base address'), |             title=_(u'Base address'), | ||||||
|             description=_(u'A base path or URL for accessing this collection ' |             description=_(u'A base path or URL for accessing this collection ' | ||||||
|                            'on the external system'), |                            'on the external system'), | ||||||
|             required=False) |             required=True) | ||||||
|     address = schema.TextLine( |     address = schema.TextLine( | ||||||
|             title=_(u'Relative address'), |             title=_(u'Relative address'), | ||||||
|             description=_(u'Optional second (local) part of the ' |             description=_(u'Optional second (local) part of the ' | ||||||
|  |  | ||||||
|  | @ -379,7 +379,7 @@ class ExternalFileAdapter(FileAdapter): | ||||||
|         self.storageName = storageName |         self.storageName = storageName | ||||||
| 
 | 
 | ||||||
|     def getData(self): |     def getData(self): | ||||||
|         if self.storageName == 'unknown':    # object not set up yet |         if self.storageName in ('unknown', None):    # object not set up yet | ||||||
|             return '' |             return '' | ||||||
|         storage = component.getUtility(IExternalStorage, name=self.storageName) |         storage = component.getUtility(IExternalStorage, name=self.storageName) | ||||||
|         return storage.getData(self.externalAddress, params=self.storageParams) |         return storage.getData(self.externalAddress, params=self.storageParams) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm