work in progress: BSCW access
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2661 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
		
							parent
							
								
									9dcb371b9e
								
							
						
					
					
						commit
						4d52ab345c
					
				
					 4 changed files with 59 additions and 12 deletions
				
			
		|  | @ -34,17 +34,49 @@ from cybertools.integrator.interfaces import IContainerFactory | ||||||
| listing_macros = ViewPageTemplateFile('listing.pt') | listing_macros = ViewPageTemplateFile('listing.pt') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class BSCWView(object): | class BaseView(object): | ||||||
| 
 |  | ||||||
|     template = listing_macros |  | ||||||
| 
 |  | ||||||
|     baseUrl = '' |  | ||||||
|     baseId = '' |  | ||||||
| 
 | 
 | ||||||
|     def __init__(self, context, request): |     def __init__(self, context, request): | ||||||
|         self.context = context |         self.context = context | ||||||
|         self.request = request |         self.request = request | ||||||
| 
 | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def title(self): | ||||||
|  |         return self.context.title | ||||||
|  | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def description(self): | ||||||
|  |         return self.context.description | ||||||
|  | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def url(self): | ||||||
|  |         return absoluteURL(self.context, self.request) | ||||||
|  | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def icon(self): | ||||||
|  |         return '%s/++resource++%s.png' % (self.request.URL[0], self.context.icon) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class ItemView(BaseView): | ||||||
|  | 
 | ||||||
|  |     def __init__(self, context, request, parentView): | ||||||
|  |         super(ItemView, self).__init__(context, request) | ||||||
|  |         self.parentView = parentView | ||||||
|  | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def url(self): | ||||||
|  |         url = self.parentView.url | ||||||
|  |         return '%s?id=%s' % (url, self.context.internalPath) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class BSCWView(BaseView): | ||||||
|  | 
 | ||||||
|  |     template = listing_macros | ||||||
|  |     itemView = ItemView | ||||||
|  | 
 | ||||||
|  |     baseUrl = '' | ||||||
|  |     baseId = '' | ||||||
|  | 
 | ||||||
|     @Lazy |     @Lazy | ||||||
|     def listing(self): |     def listing(self): | ||||||
|         return self.template.macros['listing'] |         return self.template.macros['listing'] | ||||||
|  | @ -60,7 +92,8 @@ class BSCWView(object): | ||||||
|         id = self.request.form.get('id', id) |         id = self.request.form.get('id', id) | ||||||
|         factory = component.getUtility(IContainerFactory, name='bscw') |         factory = component.getUtility(IContainerFactory, name='bscw') | ||||||
|         root = factory(id, server=server, baseUrl=self.baseUrl) |         root = factory(id, server=server, baseUrl=self.baseUrl) | ||||||
|         return root.values() |         for obj in root.values(): | ||||||
|  |             yield self.itemView(obj, self.request, self) | ||||||
| 
 | 
 | ||||||
|     def getUrlForObject(self, obj): |     def getUrlForObject(self, obj): | ||||||
|         url = absoluteURL(self.context, self.request) |         url = absoluteURL(self.context, self.request) | ||||||
|  |  | ||||||
|  | @ -4,8 +4,15 @@ | ||||||
|     <dl> |     <dl> | ||||||
|       <tal:item repeat="item view/content"> |       <tal:item repeat="item view/content"> | ||||||
|         <dt> |         <dt> | ||||||
|           <a tal:attributes="href python: view.getUrlForObject(item)" |           <a tal:attributes="href item/url"> | ||||||
|              tal:content="item/title" /> |             <img width="16" height="16" | ||||||
|  |                  src="http://localhost:8080/plone/folder_icon.gif" | ||||||
|  |                  alt="BSCW Repository" | ||||||
|  |                  tal:attributes="src item/icon" /> | ||||||
|  |           </a> | ||||||
|  |           <a tal:attributes="href item/url"> | ||||||
|  |             <span tal:content="item/title" /> | ||||||
|  |           </a> | ||||||
|         </dt> |         </dt> | ||||||
|         <dd tal:content="item/description"> |         <dd tal:content="item/description"> | ||||||
|         </dd> |         </dd> | ||||||
|  |  | ||||||
|  | @ -140,6 +140,10 @@ class Item(BSCWProxyBase, Item): | ||||||
|     def icon(self): |     def icon(self): | ||||||
|         return self.type.lower() |         return self.type.lower() | ||||||
| 
 | 
 | ||||||
|  |     @Lazy | ||||||
|  |     def type(self): | ||||||
|  |         return 'item' | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class File(BSCWProxyBase, File): | class File(BSCWProxyBase, File): | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -97,11 +97,14 @@ The BSCW Repository View | ||||||
|   >>> view.baseUrl = 'http://localhost/bscw.cgi/' |   >>> view.baseUrl = 'http://localhost/bscw.cgi/' | ||||||
|   >>> view.baseId = '4' |   >>> view.baseId = '4' | ||||||
| 
 | 
 | ||||||
|   >>> view.content() |   >>> items = list(view.content()) | ||||||
|   [<...ReadContainer...>] |   >>> items | ||||||
|  |   [<...bscw.ItemView...>] | ||||||
| 
 | 
 | ||||||
|   >>> view.getUrlForObject(view.content()[0]) |   >>> items[0].url | ||||||
|   'http://127.0.0.1/bscw?id=bs_5' |   'http://127.0.0.1/bscw?id=bs_5' | ||||||
|  |   >>> items[0].icon | ||||||
|  |   'http://127.0.0.1/++resource++folder.png' | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| Fin de partie | Fin de partie | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 helmutm
						helmutm