diff --git a/README.txt b/README.txt index f28ca4d..c90827b 100755 --- a/README.txt +++ b/README.txt @@ -536,6 +536,8 @@ A node object provides the targetSchema of its target: A node's target is rendered using the NodeView's renderTargetBody() method. This makes use of a browser view registered for the target interface, and of a lot of other stuff needed for the rendering machine. +(Note: renderTarget is obsolete - we now use a macro provided by the target's +view for rendering.) >>> from zope.component.interfaces import IFactory >>> from zope.app.renderer import rest diff --git a/browser/common.py b/browser/common.py index a783787..5ade9b5 100644 --- a/browser/common.py +++ b/browser/common.py @@ -142,16 +142,11 @@ class BaseView(GenericView): @Lazy def typeProvider(self): - type = self.type - if type is not None: - return type.typeProvider + return self.type.typeProvider @Lazy def typeInterface(self): - provider = self.typeProvider - if provider is not None: - tc = ITypeConcept(provider) - return tc.typeInterface + return self.type.typeInterface @Lazy def typeAdapter(self): @@ -161,8 +156,7 @@ class BaseView(GenericView): @Lazy def typeTitle(self): - type = self.type - return type is not None and type.title or None + return self.type.title @Lazy def typeUrl(self): diff --git a/browser/configure.zcml b/browser/configure.zcml index 4e3079a..709df79 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -562,7 +562,15 @@ + + diff --git a/browser/form.py b/browser/form.py new file mode 100644 index 0000000..e54fc0a --- /dev/null +++ b/browser/form.py @@ -0,0 +1,61 @@ +# +# 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 +# + +""" +View class for Node objects. + +$Id$ +""" + +from zope import component, interface, schema +from zope.app.pagetemplate import ViewPageTemplateFile +from zope.cachedescriptors.property import Lazy +from zope.formlib.form import Form, FormFields +from cybertools.ajax import innerHtml +from cybertools.browser.controller import FormController +from loops.browser.node import NodeView + +class CreateObjectForm(NodeView, Form): + + template = ViewPageTemplateFile('form_macros.pt') + + @property + def macro(self): return self.template.macros['create'] + + form_fields = FormFields( + schema.TextLine(__name__='title', title=_(u'Title')), + schema.Text(__name__='body', title=_(u'Body Text')), + schema.TextLine(__name__='linkUrl', title=_(u'Link'), required=False), + ) + + title = _(u'Enter Note') + form_action = 'create_resource' + + def __init__(self, context, request): + super(CreateObjectForm, self).__init__(context, request) + self.setUpWidgets() + self.widgets['body'].height = 3 + + def __call__(self): + return innerHtml(self) + + +class CreateObject(FormController): + + def update(self): + print 'updating...' diff --git a/browser/form_macros.pt b/browser/form_macros.pt index 20eaabf..a0c36c8 100644 --- a/browser/form_macros.pt +++ b/browser/form_macros.pt @@ -34,12 +34,12 @@ Assign Concept(s) - + -    - + diff --git a/browser/node.py b/browser/node.py index 4bb563c..a25458f 100644 --- a/browser/node.py +++ b/browser/node.py @@ -95,10 +95,12 @@ class NodeView(BaseView): @Lazy def item(self): + #target = self.virtualTargetObject # ignores page even for direktly assignd target target = self.request.annotations.get('loops.view', {}).get('target') # was there a .target... element in the URL? if target is not None: basicView = zapi.getMultiAdapter((target, self.request)) + # xxx: obsolete when self.targetObject is virtual target: return basicView.view return self.page @@ -139,6 +141,8 @@ class NodeView(BaseView): @Lazy def targetObject(self): + # xxx: use virtualTargetObject + #return self.virtualTargetObject return self.context.target @Lazy @@ -158,7 +162,6 @@ class NodeView(BaseView): def renderTarget(self): target = self.target - #targetAdapter = target.typeAdapter return target is not None and target.render() or u'' @Lazy @@ -242,9 +245,10 @@ class NodeView(BaseView): return item.context == self.context or item.context in self.parents def targetDefaultView(self): - target = self.request.annotations.get('loops.view', {}).get('target') - if target is None: - target = self.targetObject + target = self.virtualTargetObject + #target = self.request.annotations.get('loops.view', {}).get('target') + #if target is None: + # target = self.targetObject if target is not None: name = zapi.getDefaultViewName(target, self.request) targetView = zapi.getMultiAdapter((target, self.request), @@ -258,7 +262,7 @@ class NodeView(BaseView): def virtualTargetObject(self): target = self.request.annotations.get('loops.view', {}).get('target') if target is None: - target = self.targetObject + target = self.context.target return target @Lazy diff --git a/browser/node_macros.pt b/browser/node_macros.pt index df694f8..e381b8f 100644 --- a/browser/node_macros.pt +++ b/browser/node_macros.pt @@ -25,30 +25,34 @@
- -
- Edit -
-
- Edit -
-
+ + +
+ Edit +
+
+ Edit +
+
+
- The body + ondblclick python: target.openEditWindow('configure.html')"> + + The body +
diff --git a/browser/resource_macros.pt b/browser/resource_macros.pt index 46d7792..b8d7928 100644 --- a/browser/resource_macros.pt +++ b/browser/resource_macros.pt @@ -1,6 +1,6 @@
-

Title

+

Title