diff --git a/README.txt b/README.txt index c17269c..a116d0b 100755 --- a/README.txt +++ b/README.txt @@ -358,12 +358,6 @@ and of a lot of other stuff needed for the rendering machine. ... with=(IBrowserRequest,)) >>> from zope.component.interfaces import IFactory - >>> from zope.app.renderer import plaintext - >>> ztapi.provideUtility(IFactory, plaintext.PlainTextSourceFactory, - ... 'zope.source.plaintext') - >>> ztapi.provideAdapter(plaintext.IPlainTextSource, Interface, - ... plaintext.PlainTextToHTMLRenderer, - ... with=(IBrowserRequest,)) >>> from zope.app.renderer import rest >>> ztapi.provideUtility(IFactory, rest.ReStructuredTextSourceFactory, ... 'zope.source.rest') @@ -377,7 +371,7 @@ and of a lot of other stuff needed for the rendering machine. u'' >>> doc1.data = u'Test data\n\nAnother paragraph' >>> view.renderTargetBody() - u'Test data
\n
\nAnother paragraph' + u'Test data\n\nAnother paragraph' >>> doc1.contentType = 'text/restructured' >>> view.renderTargetBody() u'

Test data

\n

Another paragraph

\n' diff --git a/__init__.py b/__init__.py index 17abd30..d137a4a 100644 --- a/__init__.py +++ b/__init__.py @@ -28,6 +28,8 @@ from zope.app.folder.folder import Folder from zope.interface import implements from interfaces import ILoops +loopsPrefix = '.loops' + class Loops(Folder): implements(ILoops) @@ -39,5 +41,9 @@ class Loops(Folder): return self['views'] def getLoopsUri(self, obj): - return str('.loops' + zapi.getPath(obj)[len(zapi.getPath(self)):]) + return str(loopsPrefix + zapi.getPath(obj)[len(zapi.getPath(self)):]) + def loopsTraverse(self, uri): + prefix = loopsPrefix + '/' + if uri.startswith(prefix): + return zapi.traverse(self, uri[len(prefix):]) diff --git a/browser/configure.zcml b/browser/configure.zcml index fdac50a..ed06b9a 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -191,6 +191,14 @@ permission="zope.ManageContent" menu="zmi_views" title="Edit" /> + + + + - - diff --git a/browser/node_macros.pt b/browser/node_macros.pt index 586e648..bb84902 100644 --- a/browser/node_macros.pt +++ b/browser/node_macros.pt @@ -1,7 +1,7 @@ + tal:define="bodyMacro item/bodyMacro"> @@ -49,22 +49,22 @@ - -
- The body -
-
+
+
+ The body +
diff --git a/browser/resource.py b/browser/resource.py index 4d12700..a7d6d67 100644 --- a/browser/resource.py +++ b/browser/resource.py @@ -50,8 +50,9 @@ class DocumentView(object): """ Return the rendered content (data) of the context object. """ text = self.context.data - typeKey = renderingFactories.get(self.context.contentType, - renderingFactories['text/plain']) + typeKey = renderingFactories.get(self.context.contentType, None) + if typeKey is None: + return text source = zapi.createObject(typeKey, text) view = zapi.getMultiAdapter((removeAllProxies(source), self.request)) return view.render() diff --git a/browser/target.py b/browser/target.py new file mode 100644 index 0000000..5100ec3 --- /dev/null +++ b/browser/target.py @@ -0,0 +1,76 @@ +# +# Copyright (c) 2006 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 +# + +""" +Class(es) for representing a target attribute, to be used e.g. for +vocabularies and widgets. + +$Id$ +""" + +from zope.app import zapi +from zope.app.form.browser.interfaces import ITerms +from zope.schema.interfaces import IIterableSource +from zope.cachedescriptors.property import Lazy +from zope.interface import implements +from zope.security.proxy import removeSecurityProxy + + +class Term(object): + + def __init__(self, **kw): + self.__dict__.update(kw) + + +class TargetTerms(object): + + implements(ITerms) + + def __init__(self, context, request): + self.context = context.context + self.request = request + + @Lazy + def loopsRoot(self): + return self.context.getLoopsRoot() + + def getTerm(self, value): + token = self.loopsRoot.getLoopsUri(value) + #token = value.getLoopsRoot().getLoopsUri(value) + title = value.title + return Term(title=title, token=token) + + def getValue(self, token): + return self.loopsRoot.loopsTraverse(token) + + +class TargetSourceList(object): + + implements(IIterableSource) + + def __init__(self, context): + self.context = removeSecurityProxy(context) + self.resources = self.context.getLoopsRoot()['resources'] + + def __iter__(self): + return iter(self.resources.values()) + + def __len__(): + return len(self.resources) + + diff --git a/concept.py b/concept.py index 11c0b0b..5dc421b 100644 --- a/concept.py +++ b/concept.py @@ -31,7 +31,7 @@ from persistent import Persistent from cybertools.relation import DyadicRelation from cybertools.relation.registry import IRelationsRegistry, getRelations -from interfaces import IConcept +from interfaces import IConcept, IConceptView from interfaces import IConceptManager, IConceptManagerContained from interfaces import ILoopsContained @@ -54,7 +54,7 @@ class Concept(Contained, Persistent): implements(IConcept, IConceptManagerContained) - proxyInterface = IConcept + proxyInterface = IConceptView _title = u'' def getTitle(self): return self._title diff --git a/configure.zcml b/configure.zcml index e20a883..84af746 100644 --- a/configure.zcml +++ b/configure.zcml @@ -230,6 +230,17 @@ permission="zope.ManageContent" /> + + + + +