diff --git a/container/base.py b/container/base.py index b8a8bc3..03ad8ac 100644 --- a/container/base.py +++ b/container/base.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2006 Helmut Merz helmutm@cy55.de +# Copyright (c) 2008 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 @@ -22,13 +22,16 @@ Ordered container implementation. $Id$ """ -from zope.app import zapi -from zope.cachedescriptors.property import Lazy +from zope.app.pagetemplate import ViewPageTemplateFile from zope.app.container.browser.contents import JustContents from zope.app.i18n import ZopeMessageFactory as _ +from zope.cachedescriptors.property import Lazy from zope.interface import Interface +contents_template = ViewPageTemplateFile('contents.pt') + + class ContainerView(JustContents): def checkMoveAction(self): @@ -38,11 +41,13 @@ class ContainerView(JustContents): # informations for the ajax.inner.html view (template): - @Lazy - def template(self): - basicView = zapi.getMultiAdapter((self.context, self.request), - Interface, name=u'contents.html') - return basicView.index + template = contents_template + + #@Lazy + #def template(self): + # basicView = zapi.getMultiAdapter((self.context, self.request), + # Interface, name=u'contents.html') + # return basicView.index @Lazy def macro(self): diff --git a/tracking/README.txt b/tracking/README.txt index 7da8ca6..b8c73b3 100644 --- a/tracking/README.txt +++ b/tracking/README.txt @@ -134,3 +134,9 @@ We can also mark earlier runs by stopping them. >>> tracks.getRun(runId=2) + +Tracking Views +============== + + >>> from cybertools.tracking.browser import TrackingStorageView + diff --git a/tracking/browser.py b/tracking/browser.py new file mode 100644 index 0000000..ac1259a --- /dev/null +++ b/tracking/browser.py @@ -0,0 +1,94 @@ +# +# Copyright (c) 2008 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 +# + +""" +View class(es) for tracking storage and tracks. + +$Id$ +""" + +from zope import component +from zope.app.pagetemplate import ViewPageTemplateFile +from zope.cachedescriptors.property import Lazy +from zope.security.proxy import removeSecurityProxy +from zope.traversing.api import getName +from zope.traversing.browser import absoluteURL + +from cybertools.container.base import ContainerView, contents_template +from cybertools.tracking.btree import timeStamp2ISO + + +tracking_template = ViewPageTemplateFile('tracking.pt') + + +class TrackingStorageView(ContainerView): + + contents_template = contents_template + template = tracking_template + + def __call__(self): + return self.template() + + def getTracks(self): + for tr in reversed(removeSecurityProxy(self.context.values())): + view = component.queryMultiAdapter((tr, self.request)) + if view: + yield view + else: + yield TrackView(tr, self.request) + + +class TrackView(object): + + def __init__(self, context, request): + self.context = context + self.request = request + + @Lazy + def id(self): + return getName(self.context) + + @Lazy + def url(self): + return absoluteURL(self.context, self.request) + + @Lazy + def metadata(self): + return self.context.metadata + + @Lazy + def task(self): + return self.metadata['taskId'] + + taskTitle = task + taskUrl = None + + @Lazy + def run(self): + return self.metadata['runId'] + + @Lazy + def user(self): + return self.metadata['userName'] + + userTitle = user + userUrl = None + + @Lazy + def timeStamp(self): + return timeStamp2ISO(self.metadata['timeStamp']) diff --git a/tracking/tracking.pt b/tracking/tracking.pt new file mode 100644 index 0000000..bb0a0f8 --- /dev/null +++ b/tracking/tracking.pt @@ -0,0 +1,75 @@ + + + + +
+ +
+ +
+ + + +
+ Error message +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDTaskRunUserTimestamp
+ foo +
+ + + + +
+ + +
+ +