diff --git a/ajax/dojo/configure.zcml b/ajax/dojo/configure.zcml index 61bf51b..7066e5c 100644 --- a/ajax/dojo/configure.zcml +++ b/ajax/dojo/configure.zcml @@ -1,24 +1,42 @@ + xmlns:browser="http://namespaces.zope.org/browser" + xmlns:zope="http://namespaces.zope.org/zope"> - + - + + + + + + + + + + + + + permission="zope.Public" /> - + permission="zope.ManageContent" /> diff --git a/ajax/dojo/layout.py b/ajax/dojo/layout.py new file mode 100644 index 0000000..77b669e --- /dev/null +++ b/ajax/dojo/layout.py @@ -0,0 +1,53 @@ +# +# 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 +# +""" +Embed Dojo using the cybertools.composer.layout procedure. + +$Id$ +""" + +from cStringIO import StringIO +from zope.app.pagetemplate import ViewPageTemplateFile +from zope.cachedescriptors.property import Lazy + +from cybertools.browser.renderer import RendererFactory +from cybertools.composer.layout.base import Layout, LayoutInstance + +dojoRenderers = RendererFactory(ViewPageTemplateFile('macros.pt')) + + +dojo = Layout('js.dojo', 'page.js', renderer=dojoRenderers.dojo, + instanceName='dojo', order=0) + +dojoRequire = Layout('js.dojo.require', 'page.js', + renderer=dojoRenderers.dojo_require, + instanceName='dojo', order=50) + + +class DojoLayoutInstance(LayoutInstance): + + djConfig = "parseOnLoad: true, usePlainJson: true, locale: 'de'" + + @Lazy + def content(self): + djInfo = self.view.request.annotations.get('ajax.dojo', {}) + packages = djInfo.get('requirements', set()) + out = StringIO() + for p in packages: + out.write('dojo.require(%s); ' % p) + return out.getvalue() diff --git a/ajax/dojo/macros.pt b/ajax/dojo/macros.pt index c4dbb2e..8bdf994 100644 --- a/ajax/dojo/macros.pt +++ b/ajax/dojo/macros.pt @@ -1,8 +1,24 @@ - + + - + + + + + + + + + + diff --git a/commerce/interfaces.py b/commerce/interfaces.py index 002ab74..b083e70 100644 --- a/commerce/interfaces.py +++ b/commerce/interfaces.py @@ -206,6 +206,7 @@ class ICategory(Interface): shops = Attribute(u'The shops providing this category.') accessories = Attribute(u'Accessories for this category.') + # customers class ICustomer(Interface): diff --git a/composer/layout/base.py b/composer/layout/base.py index 78c775d..148d880 100644 --- a/composer/layout/base.py +++ b/composer/layout/base.py @@ -70,6 +70,13 @@ class Layout(Template): self.regionName = regionName for k, v in kw.items(): setattr(self, k, v) + #self.register() + + def register(self): + existing = component.queryUtility(ILayout, name=self.name) + if existing: + raise ValueError('Layout %s has already been registered.' % self.name) + component.provideUtility(self, provides=ILayout, name=self.name) class LayoutInstance(object): diff --git a/composer/layout/browser/standard.pt b/composer/layout/browser/standard.pt index 54bf7c1..7e3393c 100644 --- a/composer/layout/browser/standard.pt +++ b/composer/layout/browser/standard.pt @@ -14,6 +14,10 @@ + + + + @@ -37,6 +41,22 @@ + + + + + + + + + +