[Zope3-checkins] SVN: Zope3/trunk/ Added demo package for
zope.app.pageletchooser
Roger Ineichen
roger at projekt01.ch
Mon Nov 8 08:49:44 EST 2004
Log message for revision 28395:
Added demo package for zope.app.pageletchooser
Changed:
A Zope3/trunk/package-includes/pageletchooserdemo-configure.zcml
A Zope3/trunk/src/zope/app/demo/pageletchooser/
A Zope3/trunk/src/zope/app/demo/pageletchooser/README.txt
A Zope3/trunk/src/zope/app/demo/pageletchooser/__init__.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/adapters.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/app.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/__init__.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/configure.zcml
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_1.pt
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_2.pt
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/index.pt
A Zope3/trunk/src/zope/app/demo/pageletchooser/browser/views.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/configure.zcml
A Zope3/trunk/src/zope/app/demo/pageletchooser/ftests.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/interfaces.py
A Zope3/trunk/src/zope/app/demo/pageletchooser/pageletchooserdemo-configure.zcml
A Zope3/trunk/src/zope/app/demo/pageletchooser/tests.py
-=-
Added: Zope3/trunk/package-includes/pageletchooserdemo-configure.zcml
===================================================================
--- Zope3/trunk/package-includes/pageletchooserdemo-configure.zcml 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/package-includes/pageletchooserdemo-configure.zcml 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1 @@
+<include package="zope.app.demo.pageletchooser" />
Property changes on: Zope3/trunk/package-includes/pageletchooserdemo-configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/README.txt 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/README.txt 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,6 @@
+===================
+PageletChooser Demo
+===================
+
+This package demonstrates how to use the pagelet chooser. It provides a
+sample content type with registred pagelets.
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/__init__.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/__init__.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo
+
+$Id:$
+"""
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/adapters.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/adapters.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/adapters.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,99 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo
+
+$Id:$
+"""
+__docformat__ = 'restructuredtext'
+
+from persistent.dict import PersistentDict
+
+from zope.interface import implements
+from zope.interface import directlyProvides
+
+from zope.app import zapi
+
+from zope.app.annotation.interfaces import IAnnotations
+
+from zope.app.pageletchooser.interfaces import IAnnotatableMappingAdapter
+from zope.app.pageletchooser.interfaces import IPageletNameManager
+
+from zope.app.pageletchooser.adapters import AnnotatableMappingAdapter
+
+from zope.app.demo.pageletchooser.interfaces import IFirstLevelPagelets
+
+_notfound = "notfoundmacro"
+
+
+
+class MyPageletNameAccessor(AnnotatableMappingAdapter):
+ """Annotation adapter for lookup macro names by key.
+
+ Setup::
+
+ >>> from zope.interface import directlyProvides
+ >>> from zope.interface import Interface
+ >>> from zope.app.tests import placelesssetup, ztapi
+ >>> from zope.app.annotation.interfaces import IAnnotations
+ >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
+ >>> from zope.app.annotation.attribute import AttributeAnnotations
+ >>> from zope.app.pagelet.tests import TestContext
+
+ >>> placelesssetup.setUp()
+ >>> ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations
+ ... ,AttributeAnnotations)
+ >>> ztapi.provideAdapter(Interface, IAnnotatableMappingAdapter
+ ... ,MyPageletNameAccessor)
+
+ Make test object:
+
+ >>> obj = TestContext()
+ >>> directlyProvides(obj, IAttributeAnnotatable)
+
+ Test MyPageletNameAccessor:
+
+ >>> mapping = IAnnotatableMappingAdapter(obj)
+ >>> mapping.__setitem__('key1', 'value1')
+ >>> mapping['key1']
+ 'value1'
+
+ >>> mapping.__getitem__('key1')
+ 'value1'
+
+ >>> mapping.__delitem__('key1')
+ >>> mapping['key1']
+ Traceback (most recent call last):
+ ...
+ KeyError: 'key1'
+
+ >>> placelesssetup.tearDown()
+
+ """
+
+ implements(IFirstLevelPagelets, IAnnotatableMappingAdapter
+ ,IPageletNameManager)
+
+
+ def getFirstLevelMacroName(self):
+ """Get the pagelet macro name firstlevel."""
+ try:
+ return self._data['firstlevel']
+ except:
+ return _notfound
+
+ def setFirstLevelMacroName(self, value):
+ """Set the pagelet macro name firstlevel."""
+ self._data['firstlevel'] = value
+
+ firstlevel = property(getFirstLevelMacroName, setFirstLevelMacroName)
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/adapters.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/app.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/app.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/app.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo
+
+$Id:$
+"""
+__docformat__ = 'restructuredtext'
+
+from persistent import Persistent
+
+from zope.interface import implements
+
+from zope.app.container.contained import Contained
+
+from interfaces import IPageletChooserContent
+
+
+
+class PageletChooserContent(Persistent, Contained):
+ """A sample content type just for to test pagelet chooser."""
+
+ implements(IPageletChooserContent)
+
+ _title = u''
+ _description = u''
+
+ def getTitle(self):
+ """Get the title of the object."""
+ return self._title
+
+ def setTitle(self, title):
+ """Set the title of the object."""
+ self._title = title
+
+ title = property(getTitle, setTitle)
+
+ def getDescription(self):
+ """Get the description of the object."""
+ return self._description
+
+ def setDescription(self, description):
+ """Set the description of the object."""
+ self._description = description
+
+ description = property(getDescription, setDescription)
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/app.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/browser/__init__.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/browser/__init__.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo
+
+$Id:$
+"""
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/__init__.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/browser/configure.zcml 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/browser/configure.zcml 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,86 @@
+<configure
+ xmlns:zope="http://namespaces.zope.org/zope"
+ xmlns="http://namespaces.zope.org/browser"
+ i18n_domain="zope"
+ >
+
+ <!-- Pagelet chooser content -->
+ <addMenuItem
+ class="..app.PageletChooserContent"
+ title="Demo Pagelet Chooser Content"
+ description="Add a Demo Pagelet Chooser Content"
+ permission="zope.ManageContent"
+ view="zope.app.demo.pageletchooser.PageletChooserContent"
+ />
+
+ <addform
+ name="zope.app.demo.pageletchooser.PageletChooserContent"
+ label="Add a Demo Pagelet Chooser Content"
+ schema="..interfaces.IPageletChooserContent"
+ content_factory="..app.PageletChooserContent"
+ permission="zope.ManageContent"
+ />
+
+ <page
+ name="index.html"
+ menu="zmi_views" title="Index"
+ for="..interfaces.IPageletChooserContent"
+ template="index.pt"
+ class=".views.PageletChooserContentView"
+ permission="zope.View"
+ />
+
+ <editform
+ name="edit.html"
+ label="Edit"
+ for="..interfaces.IPageletChooserContent"
+ schema="..interfaces.IPageletChooserContent"
+ menu="zmi_views" title="Edit"
+ permission="zope.ManageContent"
+ />
+
+
+ <!-- three first level pagelets -->
+ <pagelet
+ name="firstlevel_macro_10"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ slot="zope.app.demo.pageletchooser.interfaces.IFirstLevelPagelets"
+ template="firstlevel_pagelet_1.pt"
+ for="..interfaces.IPageletChooserContent"
+ permission="zope.View"
+ />
+
+ <pagelet
+ name="firstlevel_macro_20"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ slot="zope.app.demo.pageletchooser.interfaces.IFirstLevelPagelets"
+ template="firstlevel_pagelet_1.pt"
+ for="..interfaces.IPageletChooserContent"
+ permission="zope.View"
+ />
+
+ <pagelet
+ name="firstlevel_macro_30"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ slot="zope.app.demo.pageletchooser.interfaces.IFirstLevelPagelets"
+ template="firstlevel_pagelet_2.pt"
+ for="..interfaces.IPageletChooserContent"
+ permission="zope.View"
+ />
+
+
+ <!-- edit view registred on the pagelet macro name schema
+ IFirstLevelPagelets. The edit view will automaticly adapt
+ the MyPageletNameAccessor adapter because he provides the
+ IFirstLevelPagelets for the IPageletChooserContent instance.
+ -->
+ <editform
+ name="select_pageletmacroname.html"
+ for="..interfaces.IPageletChooserContent"
+ schema="zope.app.demo.pageletchooser.interfaces.IFirstLevelPagelets"
+ menu="zmi_views" title="Select pagelet macro name"
+ permission="zope.ManageContent"
+ fields="firstlevel"
+ />
+
+</configure>
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_1.pt
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_1.pt 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_1.pt 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,13 @@
+<html>
+<body>
+
+<div class="row" metal:define-macro="firstlevel_macro_10">
+ <h1>Content of: firstlevel_macro_10 in firstlevel_pagelet_1.pt</h1>
+</div>
+
+<div class="row" metal:define-macro="firstlevel_macro_20">
+ <h1>Content of: firstlevel_macro_20 in firstlevel_pagelet_1.pt</h1>
+</div>
+
+</body>
+</html>
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_1.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_2.pt
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_2.pt 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_2.pt 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,9 @@
+<html>
+<body>
+
+<div class="row" metal:define-macro="firstlevel_macro_30">
+ <h1>Content of: firstlevel_macro_30 in firstlevel_pagelet_2.pt</h1>
+</div>
+
+</body>
+</html>
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/firstlevel_pagelet_2.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/index.pt
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/browser/index.pt 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/browser/index.pt 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,31 @@
+<html metal:use-macro="context/@@standard_macros/view">
+<body>
+<div metal:fill-slot="body">
+
+ <h1 i18n:translate="">PageletContent View</h1>
+
+ <div class="row">
+ <div class="label">
+ <label>Title</label>
+ </div>
+ <div class="field">
+ <span tal:content="view/title">title</span>
+ </div>
+ </div>
+
+ <div class="row">
+ <div class="label">
+ <label>Description</label>
+ </div>
+ <div class="field">
+ <span tal:content="view/description">description</span>
+ </div>
+ </div>
+
+ <div class="row">
+ <tal:block metal:use-macro="pagelet:zope.app.demo.pageletchooser.interfaces.IFirstLevelPagelets/firstlevel" />
+ </div>
+
+</div>
+
+</body></html>
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/index.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/views.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/browser/views.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/browser/views.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,39 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo
+
+$Id:$
+"""
+__docformat__ = 'restructuredtext'
+
+from zope.app.publisher.browser import BrowserView
+
+from zope.app.demo.pageletchooser.interfaces import IPageletChooserContent
+
+
+
+class PageletChooserContentView(BrowserView):
+ """Provide an index view for PageletChooserContent."""
+
+ __used_for__ = IPageletChooserContent
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def title(self):
+ return self.context.title
+
+ def description(self):
+ return self.context.description
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/browser/views.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/configure.zcml 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/configure.zcml 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,75 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:global_translation="http://namespaces.zope.org/gts"
+ i18n_domain="zope"
+ >
+
+ <!-- Sample pagelet chooser content type -->
+ <content class=".app.PageletChooserContent">
+
+ <!-- object has also to implement IAttributeAnnotatable if you store
+ the pagelet names with our adapter SamplePageletNameAnnotation
+ which is storeing the data in the annotation.
+ -->
+ <implements
+ interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ />
+
+ <implements
+ interface="zope.app.pageletchooser.interfaces.IChooseablePageletNames"
+ />
+
+ <require permission="zope.View"
+ interface=".interfaces.IPageletChooserContent"
+ />
+
+ <require permission="zope.ManageContent"
+ set_schema=".interfaces.IPageletChooserContent"
+ />
+ </content>
+
+ <!-- first level pagelet slot interface -->
+ <interface
+ interface=".interfaces.IFirstLevelPagelets" />
+
+
+ <!-- adapter for to store the pagelet macro names in the annotation.
+ If you like to sotre the pagelet macro names directly on your
+ object, then you can change the adapter to do so. For a generic
+ way to let you add pagelet macro names on object where you can't
+ change use the annotation.
+ -->
+ <adapter
+ for=".interfaces.IPageletChooserContent"
+ factory=".adapters.MyPageletNameAccessor"
+ provides="zope.app.pageletchooser.interfaces.IPageletNameManager"
+ />
+
+
+ <!-- Adapter for to let the edit view access the IPageletInfo
+ adapter. This adapter has to implement your pagelet macro name
+ interface. In our example called: IPageletChooserContentMacroNameSchema.
+ -->
+ <adapter
+ for=".interfaces.IPageletChooserContent"
+ factory=".adapters.MyPageletNameAccessor"
+ provides=".interfaces.IFirstLevelPagelets"
+ />
+
+
+ <!-- Vocabulary called 'firstlevelmacronames' for to collect the pagelet
+ macro names in the edit view. Used in the interface IMySchema.
+ ! Don't use dotted name shortcuts for slot, layer and view interfaces,
+ because we get the interfaces for this dotted strings with the iface
+ method queryInterface(). -->
+ <vocabulary
+ name="firstlevelmacronames"
+ factory="zope.app.pageletchooser.vocabulary.PageletNamesVocabulary"
+ layer="zope.publisher.interfaces.browser.IBrowserRequest"
+ view="zope.component.interfaces.IView"
+ slot="zope.app.demo.pageletchooser.interfaces.IFirstLevelPagelets"
+ />
+
+ <include package=".browser" />
+
+</configure>
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/ftests.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/ftests.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Functional tests for testing pagelet chooser content.
+
+$Id:$
+"""
+
+import unittest
+from zope.app.tests.functional import BrowserTestCase
+from zope.publisher.interfaces import NotFound
+
+
+class TestPageletChooserContent(BrowserTestCase):
+
+ def testPagelet(self):
+ # test add view
+ type_name = u'zope.app.demo.pageletchooser.PageletChooserContent'
+ response = self.publish(
+ '/+/action.html',
+ basic='mgr:mgrpw',
+ form={'type_name': type_name,
+ 'id': u'chooser'})
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'), 'http://localhost' \
+ + '/+/zope.app.demo.pageletchooser.PageletChooserContent=chooser')
+
+ # add pagelet
+ response = self.publish(
+ '/+/zope.app.demo.pageletchooser.PageletChooserContent',
+ basic='mgr:mgrpw',
+ form={'UPDATE_SUBMIT' : 'Add',
+ 'add_input_name': u'chooser',
+ 'field.title': 'aTitle'})
+ self.assertEqual(response.getStatus(), 302)
+ self.assertEqual(response.getHeader('Location'),
+ 'http://localhost/@@contents.html')
+
+ # check the content of the pagelet
+ response = self.publish('/chooser/@@index.html')
+ self.assertEqual(response.getStatus(), 200)
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('<span>aTitle</span>') >= 0)
+ self.assert_(body.find("didn't find a pagelet macro!") >= 0)
+
+ # change pagelet name
+ response = self.publish(
+ '/chooser/@@select_pageletmacroname.html',
+ basic='mgr:mgrpw',
+ form={'UPDATE_SUBMIT' : 'Change',
+ 'field.firstlevel': 'firstlevel_macro_20'})
+ self.assertEqual(response.getStatus(), 200)
+
+ # check new pagelet content
+ response = self.publish('/chooser/@@index.html')
+ self.assertEqual(response.getStatus(), 200)
+ body = ' '.join(response.getBody().split())
+ self.assert_(body.find('Content of: firstlevel_macro_20') >= 0)
+
+
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(TestPageletChooserContent),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/ftests.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/interfaces.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/interfaces.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo
+
+$Id:$
+"""
+__docformat__ = 'restructuredtext'
+
+from zope.interface import Interface
+
+from zope.schema import Text
+from zope.schema import TextLine
+from zope.schema import Choice
+
+from zope.i18n import MessageIDFactory
+_ = MessageIDFactory('zope')
+
+from zope.app.pageletchooser.interfaces import IChooseablePagelets
+
+
+
+class IPageletChooserContent(Interface):
+ """A sample content type for to test pagelet chooser."""
+
+ title = TextLine(
+ title=_(u"Title"),
+ description=_(u"Title of the sample"),
+ default=u"",
+ required=False)
+
+ description = Text(
+ title=_(u"Description"),
+ description=_(u"Description of the sample"),
+ default=u"",
+ required=False)
+
+
+
+class IFirstLevelPagelets(IChooseablePagelets):
+ """Slot for first level pagelets.
+
+ IChooseablePagelets inherited slots will use the MacroChooser
+ collector for to collect pagelet names.
+
+ The Choice field is useing the vocabulary 'firstlevelmacronames' for
+ to lookup the first level macro names and render a select box in the
+ 'edit.html' view.
+
+ """
+
+ firstlevel = Choice(
+ title = _(u"First level pagelet macro name."),
+ description = _(u"Select the first level pagelet macro name."),
+ default = 'notfoundmacro',
+ required = True,
+ vocabulary = "firstlevelmacronames",
+ )
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/interfaces.py
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/pageletchooserdemo-configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/pageletchooserdemo-configure.zcml 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/pageletchooserdemo-configure.zcml 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1 @@
+<include package="zope.app.demo.pageletchooser" />
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/pageletchooserdemo-configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/demo/pageletchooser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/pageletchooser/tests.py 2004-11-08 13:48:51 UTC (rev 28394)
+++ Zope3/trunk/src/zope/app/demo/pageletchooser/tests.py 2004-11-08 13:49:43 UTC (rev 28395)
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""PageletChooser Demo tests
+
+$Id:$
+"""
+__docformat__ = 'restructuredtext'
+
+import unittest
+from zope.testing.doctestunit import DocTestSuite
+from zope.testing.doctestunit import DocFileSuite
+
+
+def test_suite():
+ return unittest.TestSuite((
+ DocTestSuite('zope.app.demo.pageletchooser.adapters'),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
\ No newline at end of file
Property changes on: Zope3/trunk/src/zope/app/demo/pageletchooser/tests.py
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list