diff --git a/integrator/base.py b/integrator/base.py index b14b7cb..3339389 100644 --- a/integrator/base.py +++ b/integrator/base.py @@ -152,7 +152,7 @@ class Image(File): # URL info -class ExternalUrlInfo(object): +class ExternalURLInfo(object): def __init__(self, baseUrl='', path='', params=None): self.baseUrl, self.path = baseUrl.strip('/'), path.strip('/') diff --git a/integrator/browser/bscw.py b/integrator/browser/bscw.py index 47d0284..1eaef41 100644 --- a/integrator/browser/bscw.py +++ b/integrator/browser/bscw.py @@ -22,6 +22,8 @@ BSCW repository view. $Id$ """ +from datetime import datetime +from time import strptime from zope.app.pagetemplate import ViewPageTemplateFile from zope import component from zope.cachedescriptors.property import Lazy @@ -49,6 +51,10 @@ class BaseView(object): def description(self): return self.context.description + @Lazy + def modified(self): + return self.context.modified + @Lazy def url(self): return absoluteURL(self.context, self.request) @@ -76,13 +82,22 @@ class BSCWView(BaseView): itemView = ItemView @Lazy - def listing(self): - return self.viewTemplate.macros['listing'] + def dataMacro(self): + return self.viewTemplate.macros['data'] @Lazy - def heading(self): + def headingMacro(self): return self.viewTemplate.macros['heading'] + @Lazy + def itemMacro(self): + typeName = self.remoteProxy.itemType.lower() + return self.viewTemplate.macros.get(typeName, self.defaultMacro) + + @Lazy + def defaultMacro(self): + return self.viewTemplate.macros['default'] + @Lazy def remoteProxy(self): id = self.request.form.get('id') @@ -97,4 +112,3 @@ class BSCWView(BaseView): proxy = self.remoteProxy for obj in proxy.values(): yield self.itemView(obj, self.request, self) - diff --git a/integrator/browser/view.pt b/integrator/browser/view.pt index 2f62ab7..016a5c1 100644 --- a/integrator/browser/view.pt +++ b/integrator/browser/view.pt @@ -2,39 +2,67 @@ + +

Title

+

+

+ Link +

+ + + + + + +
+ + + + +
+
+
+ Link +
- -
+ +
- - - + + + — + last modified: + +
- +
diff --git a/integrator/bscw.py b/integrator/bscw.py index fefe2f5..024117f 100644 --- a/integrator/bscw.py +++ b/integrator/bscw.py @@ -23,6 +23,8 @@ $Id$ """ import os +from datetime import datetime +from time import strptime from xmlrpclib import ServerProxy from zope import component from zope.app.file.image import getImageInfo @@ -32,7 +34,7 @@ from zope.interface import implements, Attribute from cybertools.integrator.base import ContainerFactory, ItemFactory, FileFactory from cybertools.integrator.base import ReadContainer, Item, File, Image -from cybertools.integrator.base import ExternalUrlInfo +from cybertools.integrator.base import ExternalURLInfo from cybertools.integrator.interfaces import IContainerFactory from cybertools.integrator.interfaces import IItemFactory, IFileFactory from cybertools.text import mimetypes @@ -43,7 +45,7 @@ baseAttributes = ['__class__', 'name', 'id', 'descr', 'notes', 'ctime', 'mtime', 'atime', 'lastEvent', 'createEvent', 'lastChange', 'lastMove', 'containers', 'access'] -standardAttributes = ['__class__', 'name', 'id', 'descr', 'mtime'] +minimalAttributes = ['__class__', 'name', 'id', 'descr', 'mtime'] additionalAttributes = ['banner', 'moderated', 'ratings'] @@ -52,6 +54,10 @@ documentAttributes = ['vid', 'vstore', 'file_extensions', 'size', 'encoding', 't urlAttributes = ['url_link', 'last_verified', 'last_error', 'content_length', 'content_type', 'content_encoding', 'last_modified'] +standardAttributes = ['__class__', 'type', 'id', 'name', 'descr', + 'ctime', 'mtime', 'creator', 'owner', 'owner', + 'url_link', 'size', 'encoding'] + classes = ['cl_core.Folder', 'cl_core.Document', 'cl_core.URL', ] @@ -77,8 +83,7 @@ class BSCWConnection(object): self.baseURL, self.rootId = url.rsplit('/', 1) def getItem(self, address): - return self.server.get_attributes(address, - ['__class__', 'type', 'id', 'name', 'descr', 'url_link'], 1, True) + return self.server.get_attributes(address, standardAttributes, 1, True) def getProxy(self, item=None, address=None, parentPath=''): if item is None: @@ -117,11 +122,11 @@ class BSCWConnection(object): class BSCWProxyBase(object): @Lazy - def externalUrlInfo(self): + def externalURLInfo(self): id = self.address if id.startswith('bs_'): id = id[3:] - return ExternalUrlInfo(self.baseURL, id) + return ExternalURLInfo(self.baseURL, id) @Lazy def attributes(self): @@ -139,6 +144,11 @@ class BSCWProxyBase(object): def description(self): return self.properties.get('descr', u'') + @Lazy + def modified(self): + dt = self.properties['mtime'] + return dt and datetime(*(strptime(str(dt), '%Y%m%dT%H:%M:%SZ')[0:6])) or '' + class ReadContainer(BSCWProxyBase, ReadContainer): @@ -205,20 +215,17 @@ class File(BSCWProxyBase, File): return 0 +class Image(File, Image): + + pass + + # factory classes class ContainerFactory(ContainerFactory): proxyClass = ReadContainer - def xxx__call__(self, address, **kw): - server = kw.pop('server') - if isinstance(server, basestring): # just a URL, resolve for XML-RPC - server = ServerProxy(server) - baseURL = server - baseURL = kw.pop('baseURL', '') - return self.proxyClass(address, server=server, baseURL=baseURL, **kw) - class ItemFactory(ItemFactory): diff --git a/integrator/bscw.txt b/integrator/bscw.txt index a423e77..7c023f8 100644 --- a/integrator/bscw.txt +++ b/integrator/bscw.txt @@ -59,7 +59,7 @@ We can now access the root object of the BSCW repository. >>> root.description 'Public Repository' - >>> str(root.externalUrlInfo) + >>> str(root.externalURLInfo) 'http://localhost/bscw.cgi/4' Let's also have a look at the item contained in the root object. @@ -79,7 +79,7 @@ Let's also have a look at the item contained in the root object. >>> bs_5.properties {...'name': 'Introduction'...} - >>> str(bs_5.externalUrlInfo) + >>> str(bs_5.externalURLInfo) 'http://localhost/bscw.cgi/5'