[Checkins] SVN: zope3book/trunk/ content components example
Baiju M
baiju.m.mail at gmail.com
Tue Feb 24 05:04:39 EST 2009
Log message for revision 97198:
content components example
Changed:
A zope3book/trunk/code/10_content_components/
A zope3book/trunk/code/10_content_components/stage1/
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/bootstrap/
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/bootstrap/bootstrap.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/buildout.cfg
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/setup.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/__init__.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/application.zcml
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/browser.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/comment.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/configure.zcml
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/interfaces.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/__init__.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/test_collector.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticket.py
A zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticketcollector.py
U zope3book/trunk/source/content-components.rst
-=-
Property changes on: zope3book/trunk/code/10_content_components/stage1/ticketcollector
___________________________________________________________________
Added: svn:ignore
+ develop-eggs
eggs
bin
parts
.installed.cfg
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/bootstrap/bootstrap.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/bootstrap/bootstrap.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/bootstrap/bootstrap.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,55 @@
+##############################################################################
+#
+# Copyright (c) 2006 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 75593 2007-05-06 21:11:27Z jim $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+ import pkg_resources
+except ImportError:
+ ez = {}
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+ import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/buildout.cfg
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/buildout.cfg (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/buildout.cfg 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,25 @@
+[buildout]
+develop = .
+parts = ticketcollectorapp instance test
+extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg
+versions = versions
+
+[zope3]
+location =
+
+[ticketcollectorapp]
+recipe = zc.zope3recipes:app
+site.zcml = <include package="ticketcollector" file="application.zcml" />
+eggs = ticketcollector
+
+[instance]
+recipe = zc.zope3recipes:instance
+application = ticketcollectorapp
+zope.conf = ${database:zconfig}
+
+[database]
+recipe = zc.recipe.filestorage
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = ticketcollector
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/setup.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/setup.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/setup.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,17 @@
+from setuptools import setup, find_packages
+
+setup(
+ name='ticketcollector',
+ version='0.1',
+
+ packages=find_packages('src'),
+ package_dir={'': 'src'},
+
+ install_requires=['setuptools',
+ 'zope.app.zcmlfiles',
+ 'zope.app.twisted',
+ 'zope.app.securitypolicy',
+ ],
+ include_package_data=True,
+ zip_safe=False,
+ )
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/__init__.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/__init__.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/__init__.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1 @@
+#Python package
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/application.zcml
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/application.zcml (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/application.zcml 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,58 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="zope"
+ >
+<include package="zope.app.securitypolicy" file="meta.zcml" />
+
+<include package="zope.app.zcmlfiles" />
+<include package="zope.app.authentication" />
+<include package="zope.app.securitypolicy" />
+<include package="zope.app.twisted" />
+
+<securityPolicy
+ component="zope.app.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+<role id="zope.Anonymous" title="Everybody"
+ description="All users have this role implicitly" />
+<role id="zope.Manager" title="Site Manager" />
+<role id="zope.Member" title="Site Member" />
+
+<grant permission="zope.View"
+ role="zope.Anonymous" />
+<grant permission="zope.app.dublincore.view"
+ role="zope.Anonymous" />
+
+<grantAll role="zope.Manager" />
+
+<unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User" />
+
+<unauthenticatedGroup
+ id="zope.Anybody"
+ title="Unauthenticated Users" />
+
+<authenticatedGroup
+ id="zope.Authenticated"
+ title="Authenticated Users" />
+
+<everybodyGroup
+ id="zope.Everybody"
+ title="All Users" />
+
+<principal
+ id="zope.manager"
+ title="Manager"
+ login="admin"
+ password_manager="Plain Text"
+ password="admin"
+ />
+
+<grant
+ role="zope.Manager"
+ principal="zope.manager" />
+
+<include package="ticketcollector" />
+
+</configure>
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/browser.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/browser.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/browser.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,15 @@
+from zope.publisher.browser import BrowserView
+
+class HelloView(BrowserView):
+
+ def __call__(self):
+ return """
+ <html>
+ <head>
+ <title>Hello World</title>
+ </head>
+ <body>
+ Hello World
+ </body>
+ </html>
+ """
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/comment.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/comment.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/comment.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,28 @@
+from zope.interface import implements
+
+from interfaces import IComment
+from interfaces import ICommentContained
+from zope.app.container.contained import Contained
+
+class Comment(Contained):
+ """A simple implementation of a comment.
+
+ Make sure that the ``Comment`` implements the ``IComment`` interface::
+
+ >>> from zope.interface.verify import verifyClass
+ >>> verifyClass(IComment, Comment)
+ True
+
+ Here is an example of changing the body of the comment::
+
+ >>> comment = Comment()
+ >>> comment.body
+ u''
+ >>> comment.body = u'Comment Body'
+ >>> comment.body
+ u'Comment Body'
+ """
+
+ implements(IComment, ICommentContained)
+
+ body = u""
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/configure.zcml
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/configure.zcml (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/configure.zcml 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,70 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="collector">
+
+ <interface
+ interface=".interfaces.ICollector"
+ type="zope.app.content.interfaces.IContentType"
+ />
+
+ <class class=".ticketcollector.Collector">
+ <implements
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
+ />
+ <implements
+ interface="zope.app.container.interfaces.IContentContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ set_schema=".interfaces.ICollector"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface=".interfaces.ICollector"
+ />
+ </class>
+
+ <interface
+ interface=".interfaces.ITicket"
+ type="zope.app.content.interfaces.IContentType"
+ />
+
+ <class class=".ticket.Ticket">
+ <implements
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
+ />
+ <implements
+ interface="zope.app.container.interfaces.IContentContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ set_schema=".interfaces.ITicket"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface=".interfaces.ITicket"
+ />
+ </class>
+
+ <interface
+ interface=".interfaces.IComment"
+ type="zope.app.content.interfaces.IContentType"
+ />
+
+ <class class=".comment.Comment">
+ <implements
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
+ />
+ <require
+ permission="zope.ManageContent"
+ set_schema=".interfaces.IComment"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface=".interfaces.IComment"
+ />
+ </class>
+
+ <include package=".browser" />
+
+</configure>
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/interfaces.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/interfaces.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/interfaces.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,56 @@
+from zope.interface import Interface
+from zope.schema import Text, TextLine, Field
+
+from zope.app.container.constraints import containers, contains
+from zope.app.container.interfaces import IContained, IContainer
+
+class IComment(Interface):
+ """Comment for Ticket"""
+
+ body = Text(
+ title=u"Additional Comment",
+ description=u"Body of the Comment.",
+ default=u"",
+ required=True)
+
+class ITicket(IContainer):
+ """A ticket object."""
+
+ summary = TextLine(
+ title=u"Summary",
+ description=u"Short summary",
+ default=u"",
+ required=True)
+
+ description = Text(
+ title=u"Description",
+ description=u"Full description",
+ default=u"",
+ required=False)
+
+ contains('.IComment')
+
+class ICollector(IContainer):
+ """Collector the base object. It can only
+ contains ITicket objects."""
+
+ contains('.ITicket')
+
+ description = Text(
+ title=u"Description",
+ description=u"A description of the collector.",
+ default=u"",
+ required=False)
+
+
+class ITicketContained(IContained):
+ """Interface that specifies the type of objects that can contain
+ tickets. So a ticket can only contain in a collector."""
+
+ containers(ICollector)
+
+class ICommentContained(IContained):
+ """Interface that specifies the type of objects that can contain
+ comments. So a comment can only contain in a ticket."""
+
+ containers(ITicket)
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/__init__.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/__init__.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/__init__.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1 @@
+#Python package
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/test_collector.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/test_collector.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/tests/test_collector.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,21 @@
+import unittest
+from zope.testing.doctestunit import DocTestSuite
+
+from zope.app.container.tests.test_icontainer import TestSampleContainer
+
+from ticketcollector.ticketcollector import Collector
+
+
+class Test(TestSampleContainer):
+
+ def makeTestObject(self):
+ return Collector()
+
+def test_suite():
+ return unittest.TestSuite((
+ DocTestSuite('ticketcollector.ticketcollector'),
+ unittest.makeSuite(Test),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticket.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticket.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticket.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,35 @@
+from zope.interface import implements
+from zope.interface import classProvides
+from zope.app.container.btree import BTreeContainer
+from zope.app.container.contained import Contained
+
+from interfaces import ITicket, ITicketContained
+
+class Ticket(BTreeContainer, Contained):
+ """A simple implementation of a ticket using B-Tree Containers.
+
+ Make sure that the ``Ticket`` implements the ``ITicket`` interface::
+
+ >>> from zope.interface.verify import verifyClass
+ >>> verifyClass(ITicket, Ticket)
+ True
+
+ Here is an example of changing the summary and description of the ticket::
+
+ >>> ticket = Ticket()
+ >>> ticket.summary
+ u''
+ >>> ticket.description
+ u''
+ >>> ticket.summary = u'Ticket Summary'
+ >>> ticket.description = u'Ticket Description'
+ >>> ticket.summary
+ u'Ticket Summary'
+ >>> ticket.description
+ u'Ticket Description'
+ """
+
+ implements(ITicket, ITicketContained)
+
+ summary = u''
+ description = u''
Added: zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticketcollector.py
===================================================================
--- zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticketcollector.py (rev 0)
+++ zope3book/trunk/code/10_content_components/stage1/ticketcollector/src/ticketcollector/ticketcollector.py 2009-02-24 10:04:39 UTC (rev 97198)
@@ -0,0 +1,29 @@
+from zope.interface import implements
+from zope.app.container.btree import BTreeContainer
+
+from interfaces import ICollector
+
+class Collector(BTreeContainer):
+ """A simple implementation of a collector using B-Tree
+ Containers.
+
+ Make sure that the ``Collector`` implements the ``ICollector``
+ interface::
+
+ >>> from zope.interface.verify import verifyClass
+ >>> verifyClass(ICollector, Collector)
+ True
+
+ Here is an example of changing the description of the collector::
+
+ >>> collector = Collector()
+ >>> collector.description
+ u''
+ >>> collector.description = u'Ticket Collector Description'
+ >>> collector.description
+ u'Ticket Collector Description'
+ """
+
+ implements(ICollector)
+
+ description = u''
Modified: zope3book/trunk/source/content-components.rst
===================================================================
--- zope3book/trunk/source/content-components.rst 2009-02-24 07:50:58 UTC (rev 97197)
+++ zope3book/trunk/source/content-components.rst 2009-02-24 10:04:39 UTC (rev 97198)
@@ -184,8 +184,9 @@
contains('.IComment')
class ICommentContained(IContained):
- """Interface that specifies the type of objects that can contain
- comments. So a comment can contain in a ticket or a comment itself."""
+ """Interface that specifies the type of objects that can
+ contain comments. So a comment can contain in a ticket or a
+ comment itself."""
containers(ITicket, IComment)
More information about the Checkins
mailing list