[Checkins] SVN: z3c.feature.zope/trunk/ initial import

Paul Carduner paulcarduner at gmail.com
Fri Mar 27 04:54:36 EDT 2009


Log message for revision 98395:
  initial import

Changed:
  A   z3c.feature.zope/trunk/
  A   z3c.feature.zope/trunk/bootstrap.py
  A   z3c.feature.zope/trunk/buildout.cfg
  A   z3c.feature.zope/trunk/setup.py
  A   z3c.feature.zope/trunk/src/
  A   z3c.feature.zope/trunk/src/z3c/
  A   z3c.feature.zope/trunk/src/z3c/__init__.py
  A   z3c.feature.zope/trunk/src/z3c/feature/
  A   z3c.feature.zope/trunk/src/z3c/feature/__init__.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/README.txt
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/__init__.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/browser.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/content.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/content.txt
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/file-templates/
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/file-templates/simple-page.pt
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/index.txt
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/interfaces.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/project.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/skin.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/template.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/tests.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/web/
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/web/__init__.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/web/content.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/web/page.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/web/project.py
  A   z3c.feature.zope/trunk/src/z3c/feature/zope/zope-project.xml

-=-
Added: z3c.feature.zope/trunk/bootstrap.py
===================================================================
--- z3c.feature.zope/trunk/bootstrap.py	                        (rev 0)
+++ z3c.feature.zope/trunk/bootstrap.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2007 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$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+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)


Property changes on: z3c.feature.zope/trunk/bootstrap.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/buildout.cfg
===================================================================
--- z3c.feature.zope/trunk/buildout.cfg	                        (rev 0)
+++ z3c.feature.zope/trunk/buildout.cfg	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,33 @@
+[buildout]
+extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg
+develop = .
+          ../z3c.builder.core
+          ../z3c.feature.core
+parts = python test coverage-test coverage-report
+versions = versions
+
+[python]
+recipe = zc.recipe.egg
+interpreter = py
+eggs = z3c.feature.zope
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.feature.zope [test]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3c.feature.zope [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
+
+[gtkeggdeps]
+recipe = zc.recipe.egg
+scripts = gtkeggdeps
+eggs = gtkeggdeps
+       z3c.feature.zope

Added: z3c.feature.zope/trunk/setup.py
===================================================================
--- z3c.feature.zope/trunk/setup.py	                        (rev 0)
+++ z3c.feature.zope/trunk/setup.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# Copyright (c) 2009 Paul Carduner and Stephan Richter.
+# 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.
+#
+##############################################################################
+
+"""Setup"""
+from setuptools import setup, find_packages
+
+setup (
+    name = 'z3c.feature.zope',
+    version = '0.1.0',
+    author = u"Paul Carduner and Stephan Richter",
+    author_email = u"zope-dev at zope.org",
+    description = u"Zope Features to use with z3c.builder.core",
+    license = "ZPL",
+    keywords = u"zope3 project builder feature",
+    url = "http://pypi.python.org/pypi/z3c.feature.zope",
+    packages = find_packages('src'),
+    include_package_data = True,
+    package_dir = {'':'src'},
+    namespace_packages = ['z3c','z3c.feature'],
+    extras_require = {
+        'test':[
+            'zope.testing',
+            'z3c.coverage',
+            ],
+        },
+    install_requires = [
+        'setuptools',
+        'z3c.builder.core',
+        'z3c.feature.core',
+        ],
+    zip_safe = False,
+    entry_points = """
+    [z3c.boiler.template]
+    zope-project = z3c.feature.zope.template:ZopeProjectTemplate
+
+    [z3c.feature]
+    zope-project = z3c.feature.zope.project:ZopeProjectFeature
+    zope-page = z3c.feature.zope.browser:ZopePageFeature
+    zope-skin = z3c.feature.zope.skin:ZopeSkinFeature
+    content-type = z3c.feature.zope.content:ZopeContentFeature
+
+    [z3c.builderweb]
+    zope-page = z3c.feature.zope.web.page:ZopePageWebFeature
+    zope-project = z3c.feature.zope.web.project:ZopeProjectWebFeature
+    content-type = z3c.feature.zope.web.content:ZopeContentWebFeature
+    """,
+    )


Property changes on: z3c.feature.zope/trunk/setup.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/__init__.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/__init__.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/__init__.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,7 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace(__name__)
+except ImportError:
+    pass
+


Property changes on: z3c.feature.zope/trunk/src/z3c/__init__.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/__init__.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/__init__.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/__init__.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,6 @@
+try:
+    # Declare this a namespace package if pkg_resources is available.
+    import pkg_resources
+    pkg_resources.declare_namespace(__name__)
+except ImportError:
+    pass


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/__init__.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/README.txt
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/README.txt	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/README.txt	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,351 @@
+=========================
+Zope-Related Web Features
+=========================
+
+This page contains features that are specific to Zope projects.
+
+
+Zope Project Feature
+--------------------
+
+The Zope project feature converts a project from a simple Buildout project to
+a full Zope server installation.
+
+  >>> from z3c.feature.zope import project
+  >>> zprj = project.ZopeProjectFeature()
+  >>> zprj
+  <ZopeProjectFeature u'Zope Project'>
+
+Clearly, the Zope Project Feature implements its own interface:
+
+  >>> from zope.interface.verify import verifyObject
+  >>> from z3c.feature.zope import interfaces
+
+  >>> verifyObject(interfaces.IZopeProjectFeature, zprj)
+  True
+
+Each feature must provide a title and some documentation:
+
+  >>> print zprj.featureTitle
+  Zope Project
+
+  >>> print zprj.featureDocumentation
+  This feature extends a buildout project to a Zope project.
+
+Let's now create a project to which we can apply the feature.
+
+  >>> from z3c.builder.core.project import BuildoutProjectBuilder
+  >>> demo = BuildoutProjectBuilder(u'demo')
+
+  >>> zprj.applyTo(demo)
+
+The easiest way to see what the feature added is by rendering the project
+itself.
+
+  >>> demo.update()
+  >>> demo.write(buildPath)
+
+  >>> ls(buildPath)
+  demo/
+    bootstrap.py
+    buildout.cfg
+    setup.py
+    src/
+      demo/
+        __init__.py
+        application.zcml
+        configure.zcml
+        browser/
+          __init__.py
+          configure.zcml
+
+You immediately notice that there are several files:
+
+- `browser/` - This is a placeholder sub-package for all browser-related
+  code. It contains a placeholder configuration file.
+
+    >>> more(buildPath, 'demo', 'src', 'demo', 'browser', 'configure.zcml')
+    <configure
+        i18n_domain="demo"
+        />
+
+- `application.zcml` - This file contains all the necessary includes
+  to make the Zope 3 application run.
+
+    >>> more(buildPath, 'demo', 'src', 'demo', 'application.zcml')
+    <configure
+        xmlns:zope="http://namespaces.zope.org/zope"
+        xmlns:browser="http://namespaces.zope.org/browser"
+        i18n_domain="demo"
+        >
+      <zope:include
+          package="zope.app.component"
+          file="meta.zcml"
+          />
+      ...
+      <browser:menu
+          title="Views"
+          id="zmi_views"
+          />
+      <browser:menu
+          title="Actions"
+          id="zmi_actions"
+          />
+      <zope:include
+          package="zope.app.appsetup"
+          />
+      ...
+      <browser:defaultView
+          name="index.html"
+          />
+      <zope:securityPolicy
+          component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+          />
+      <zope:role
+          title="Everybody"
+          id="zope.Anonymous"
+          />
+      <zope:grantAll
+          role="zope.Anonymous"
+          />
+    </configure>
+
+- `configure.zcml` - This is a simple placeholder configuration file for
+  future use.
+
+    >>> more(buildPath, 'demo', 'src', 'demo', 'configure.zcml')
+    <configure
+        xmlns:zope="http://namespaces.zope.org/zope"
+        i18n_domain="demo"
+        >
+      <zope:include
+          package=".browser"
+          />
+    </configure>
+
+Clearly with so many references to other packages, the setup file must also
+list dependencies.
+
+  >>> more(buildPath, 'demo', 'setup.py')
+  ##############################################################################
+  #
+  # This file is part of demo...
+  #
+  ##############################################################################
+  """Setup"""
+  from setuptools import setup, find_packages
+  <BLANKLINE>
+  setup (
+      name = 'demo',
+      version = '0.1.0',
+      author = u"",
+      author_email = u"",
+      description = u"",
+      license = "GPLv3",
+      keywords = u"",
+      url = "http://pypi.python.org/pypi/demo",
+      classifiers = [],
+      packages = find_packages('src'),
+      include_package_data = True,
+      package_dir = {'':'src'},
+      namespace_packages = [],
+      extras_require = {},
+      install_requires = [
+          'setuptools',
+          'zdaemon',
+          ...
+          ],
+      zip_safe = False,
+      entry_points = {},
+      )
+
+Also, the buildout configuration file contain multiple new sections that setup
+the application server
+
+  >>> more(buildPath, 'demo', 'buildout.cfg')
+  [buildout]
+  extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg
+  develop = .
+  parts = demo-app demo
+  versions = versions
+  <BLANKLINE>
+  [zope3]
+  location = .
+  <BLANKLINE>
+  [demo-app]
+  recipe = zc.zope3recipes:app
+  site.zcml = <include package="demo" file="application.zcml" />
+  eggs = demo
+  <BLANKLINE>
+  [demo]
+  recipe = zc.zope3recipes:instance
+  application = demo-app
+  zope.conf = ${database:zconfig}
+  eggs = demo
+  <BLANKLINE>
+  [database]
+  recipe = zc.recipe.filestorage
+
+
+Zope Browser Layer Feature
+--------------------------
+
+Not yet done.
+
+
+Zope Page Feature
+-----------------
+
+This feature installs a simple page. It provides a few options that alter the
+outcome of the generation.
+
+  >>> from z3c.feature.zope import browser
+  >>> page = browser.ZopePageFeature()
+  >>> page
+  <ZopePageFeature u'Zope Page (index.html)'>
+
+Clearly, the feature implements its own interface:
+
+  >>> verifyObject(interfaces.IZopePageFeature, page)
+  True
+
+Each feature must provide a title and some documentation:
+
+  >>> print page.featureTitle
+  Zope Page (index.html)
+
+  >>> print page.featureDocumentation
+  The Zope Page Feature creates a simple Zope 3 style page.
+
+This particular feature has some additional fields that can be customized.
+
+  >>> print page.name
+  index.html
+  >>> print page.templateName
+  None
+
+If we change the page name, the feature title changes as well.
+
+  >>> page.name = u"page.html"
+  >>> print page.featureTitle
+  Zope Page (page.html)
+
+Now that we have the page setup, let's apply it to the project and render the
+project again.
+
+  >>> page.update()
+  >>> page.applyTo(demo)
+
+  >>> demo.update()
+  >>> demo.write(buildPath, True)
+
+  >>> ls(buildPath)
+  demo/
+    bootstrap.py
+    buildout.cfg
+    setup.py
+    src/
+      demo/
+        __init__.py
+        application.zcml
+        configure.zcml
+        browser/
+          __init__.py
+          configure.zcml
+          page.pt
+
+The page template is the simplest HTML page possible:
+
+  >>> more(buildPath, 'demo', 'src', 'demo', 'browser', 'page.pt')
+  <html>
+    <head>
+      <title>Simple Page</title>
+    </head>
+    <body>
+      <h1>Simple Page</h1>
+    </body>
+  </html>
+
+The configuration file also registers the page:
+
+  >>> more(buildPath, 'demo', 'src', 'demo', 'browser', 'configure.zcml')
+  <configure
+      xmlns:browser="http://namespaces.zope.org/browser"
+      i18n_domain="demo"
+      >
+    <browser:page
+        template="page.pt"
+        for="*"
+        name="page.html"
+        permission="zope.Public"
+        />
+  </configure>
+
+Pretty simple.
+
+Bulding the Project
+-------------------
+
+Before we can build the project, we need to install the Python interpreter
+feature and re-render the project.
+
+  >>> from z3c.feature.core import python
+  >>> interpreter = python.PythonInterpreterFeature()
+  >>> interpreter.applyTo(demo)
+
+  >>> demo.update()
+  >>> demo.write(buildPath, True)
+
+Let's now build the project to see whether it all works.
+
+  >>> import sys
+  >>> projectDir = buildPath + '/demo'
+
+  >>> print cmd((sys.executable, 'bootstrap.py'), projectDir)
+  Exit Status: 0...
+  Downloading http://pypi.python.org/packages/2.5/s/setuptools/setuptools-...
+  Creating directory '.../demo/bin'.
+  Creating directory '.../demo/parts'.
+  Creating directory '.../demo/develop-eggs'.
+  Generated script '.../demo/bin/buildout'.
+
+  >>> print cmd(('./bin/buildout', '-N'), projectDir)
+  Exit Status: 0
+  Develop: '.../demo/.'
+  Installing demo-app.
+  Generated script '.../demo/parts/demo-app/runzope'.
+  Generated script '.../demo/parts/demo-app/debugzope'.
+  Installing database.
+  Installing demo.
+  Generated script '.../demo/bin/demo'.
+  Installing python.
+  Generated interpreter '.../demo/bin/python'.
+
+Let's now load the configuration to check that we have a fully functioning
+package.
+
+  >>> testCode = '''
+  ... import zope.app.twisted.main
+  ... from zc.zope3recipes import debugzope
+  ... options = debugzope.load_options(
+  ...     ('-C', '%(dir)s/parts/demo/zope.conf',),
+  ...     zope.app.twisted.main)
+  ... folder = debugzope.zglobals(options.configroot)['root']
+  ...
+  ... import zope.component
+  ... from zope.publisher.browser import TestRequest
+  ... page = zope.component.getMultiAdapter(
+  ...     (folder, TestRequest()), name='page.html')
+  ... print page()
+  ... ''' % {'dir': projectDir}
+
+  >>> print cmd(('./bin/python', '-c', testCode), projectDir)
+  Exit Status: 0
+  <html>
+    <head>
+      <title>Simple Page</title>
+    </head>
+    <body>
+      <h1>Simple Page</h1>
+    </body>
+  </html>


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/README.txt
___________________________________________________________________
Added: svn:eol-style
   + native

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/__init__.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/__init__.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/__init__.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1 @@
+# Make a package.


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/__init__.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/browser.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/browser.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/browser.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,67 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Zope Page Features
+
+$Id$
+"""
+import os
+import zope.interface
+from zope.schema.fieldproperty import FieldProperty
+
+from z3c.builder.core import base, project, zcml
+from z3c.feature.core.base import BaseFeature
+from z3c.feature.zope import interfaces
+
+PAGE_DOCUMENTATION = """
+The Zope Page Feature creates a simple Zope 3 style page.
+"""
+
+class ZopePageFeature(BaseFeature):
+    zope.interface.implements(interfaces.IZopePageFeature)
+
+    featureTitle = u'Zope Page'
+    featureDocumentation = PAGE_DOCUMENTATION
+    featureSingleton = False
+
+    name = FieldProperty(interfaces.IZopePageFeature['name'])
+    templateName = FieldProperty(interfaces.IZopePageFeature['templateName'])
+
+    @property
+    def featureTitle(self):
+        return u'Zope Page (%s)' % self.name
+
+    def update(self):
+        if not self.templateName:
+            self.templateName = self.name.split('.')[0]+'.pt'
+        super(ZopePageFeature, self).update()
+
+    def _applyTo(self, project):
+        project.package['browser'].add(
+            base.SimpleFileBuilder(
+                self.templateName,
+                os.path.join(os.path.dirname(__file__),
+                             'file-templates', 'simple-page.pt')
+                )
+            )
+        config = project.package['browser']['configure']
+        config.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.BROWSER_NS,
+            name = u'page',
+            attributes = {
+                'name': self.name,
+                'for': '*',
+                'template': 'page.pt',
+                'permission': 'zope.Public'}
+            ))
+


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/browser.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/content.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/content.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/content.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,212 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Zope Content-type feature.
+
+$Id$
+"""
+import os
+import zope.interface
+from zope.schema.fieldproperty import FieldProperty
+
+from z3c.builder.core import project, zcml, python, form
+from z3c.feature.core import base, xml
+from z3c.feature.zope import interfaces
+
+CONTENT_DOCUMENTATION = """
+The Zope Content Feature lets you define a basic content type that can
+be stored in a database and that has a simple page for creating,
+reading, updating, and deleting the content item.
+"""
+
+class ZopeContentFeature(base.BaseFeature):
+    zope.interface.implements(interfaces.IZopeContentFeature)
+
+    featureDocumentation = CONTENT_DOCUMENTATION
+    featureSingleton = False
+    featureDependencies = ('zope-project','zope-skin')
+
+    className = FieldProperty(interfaces.IZopeContentFeature['className'])
+    classFile = FieldProperty(interfaces.IZopeContentFeature['classFile'])
+    fields = FieldProperty(interfaces.IZopeContentFeature['fields'])
+
+
+    @property
+    def featureTitle(self):
+        return u'Zope Content Type (%s)' % self.className
+
+    def __init__(self):
+        self.fields = {}
+
+    def addField(self, name, schemaType):
+        constraint = interfaces.IZopeContentFeature['fields']
+        constraint.key_type.validate(name)
+        constraint.value_type.validate(schemaType)
+        self.fields[name] = schemaType
+
+    def update(self, features=()):
+        if not self.classFile:
+            self.classFile = self.className.lower()+'.py'
+
+    @classmethod
+    def fromXMLNode(cls, node, omit=()):
+        feature = cls()
+        schema = base.getFeatureSchema(feature)
+        for fieldName in ('className','classFile'):
+            matches = node.xpath('./%s'%fieldName)
+            match = matches[0] if matches else None
+            if match is not None:
+                setattr(feature, fieldName, unicode(match.text))
+        for field in node.xpath('./fields/field'):
+            feature.addField(unicode(field.get('name')),
+                             unicode(field.get('type')))
+        return feature
+
+    def _applyTo(self, project):
+        # Step 1: build the interface
+        ifaces = project.package['interfaces.py']
+
+        iface = python.InterfaceBuilder(u'I%s' % self.className)
+        iface.docstring = str("The ``%s`` Content Type" % self.className)
+        ifaces.add(iface)
+
+        for fieldName, fieldType in self.fields.items():
+            iface.add(python.FieldBuilder(
+                name=fieldName,
+                type=str(fieldType),
+                title=fieldName.capitalize()))
+
+        # Step 2: build the implementation
+        if self.classFile not in project.package.keys():
+            project.package.add(python.ModuleBuilder(self.classFile))
+        module = project.package[self.classFile]
+
+        classDefinition = python.ClassFromInterfaceBuilder(
+            name=self.className,
+            interface=iface,
+            bases = ('persistent.Persistent',
+                     'zope.container.contained.Contained'))
+        module.add(classDefinition)
+
+        # Step 3: build the configuration
+        if 'configure' not in project.package.keys():
+            project.package.add(zcml.ZCMLFileBuilder(u'configure.zcml'))
+        configure = project.package['configure']
+
+        classDirective = zcml.ZCMLDirectiveBuilder(
+            namespace=zcml.ZOPE_NS,
+            name='class',
+            attributes={'class':classDefinition.getPythonPath()})
+        configure.add(classDirective)
+
+        classDirective.add(zcml.ZCMLDirectiveBuilder(
+            namespace=None,
+            name='allow',
+            attributes={'interface':iface.getPythonPath()}))
+        classDirective.add(zcml.ZCMLDirectiveBuilder(
+            namespace=None,
+            name='require',
+            attributes={'permission':'zope.Public',
+                        'set_schema':iface.getPythonPath()}))
+
+        browser = project.package['browser']
+
+        # Step 4: make sure the browser package has configuration in it.
+        if 'configure' not in browser.keys():
+            browser.add(zcml.ZCMLFileBuilder(u'configure.zcml'))
+            configure.add(zcml.ZCMLDirectiveBuilder(
+                namespace = zcml.ZOPE_NS,
+                name = 'include',
+                attributes={'package':browser.getPythonPath()}))
+        browserConfig = browser['configure']
+
+        # Step 5: create the form module.
+        if 'z3c.form' not in project.setup.install_requires:
+            project.setup.install_requires.append('z3c.form')
+        project.package['appConfig'].add(
+            zcml.ZCMLDirectiveBuilder(
+                namespace = zcml.ZOPE_NS,
+                name = 'include',
+                attributes={'package':'z3c.form','file':'meta.zcml'})
+            )
+        project.package['appConfig'].add(
+            zcml.ZCMLDirectiveBuilder(
+                namespace = zcml.ZOPE_NS,
+                name = 'include',
+                attributes={'package':'z3c.form'})
+            )
+        layerIface = project.package['interfaces.py']['ILayer']
+        skinIface = project.package['interfaces.py']['ISkin']
+        if 'z3c.form.interfaces.IFormLayer' not in skinIface.bases:
+            skinIface.bases.append('z3c.form.interfaces.IFormLayer')
+
+        formModule = python.ModuleBuilder(self.classFile)
+        browser.add(formModule)
+
+        # Step 5.1: create the add form and register it
+        addForm = form.AddFormBuilder(
+            name=u'%sAddForm' % self.className,
+            #TODO: make add form builder accept an interface builder.
+            interface=str(iface.getPythonPath()),
+            fields=iface.keys(),
+            factory=str(classDefinition.getPythonPath()),
+            next='index.html')
+        formModule.add(addForm)
+        browserConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace=zcml.BROWSER_NS,
+            name=u'page',
+            attributes = {
+                'name': 'index.html',
+                'for': 'zope.app.folder.interfaces.IFolder',
+                #TODO: make add forms support a getPythonPath method...
+                'class': '%s.%s'%(formModule.getPythonPath(),
+                                  addForm.name),
+                'permission': 'zope.Public',
+                'layer':layerIface.getPythonPath()}))
+
+
+        # Step 5.2 create the edit form and register it.
+        editForm = form.EditFormBuilder(
+            name=u'%sEditForm' % self.className,
+            interface=str(iface.getPythonPath()),
+            fields=iface.keys())
+        formModule.add(editForm)
+        browserConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace=zcml.BROWSER_NS,
+            name=u'page',
+            attributes = {
+                'name': 'edit.html',
+                'for': str(iface.getPythonPath()),
+                #TODO: make add forms support a getPythonPath method...
+                'class': '%s.%s'%(formModule.getPythonPath(),
+                                    editForm.name),
+                'permission': 'zope.Public',
+                'layer':layerIface.getPythonPath()}))
+
+        # Step 5.3 create the display form and register it.
+        displayForm = form.SimpleDisplayFormBuilder(
+            name=u'%sDisplayForm' % self.className,
+            interface=str(iface.getPythonPath()),
+            fields=iface.keys())
+        formModule.add(displayForm)
+        browserConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace=zcml.BROWSER_NS,
+            name=u'page',
+            attributes = {
+                'name': 'index.html',
+                'for': str(iface.getPythonPath()),
+                #TODO: make add forms support a getPythonPath method...
+                'class': '%s.%s'%(formModule.getPythonPath(),
+                                    displayForm.name),
+                'permission': 'zope.Public',
+                'layer':layerIface.getPythonPath()}))


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/content.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/content.txt
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/content.txt	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/content.txt	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,252 @@
+====================
+Zope Content Feature
+====================
+
+    >>> from z3c.feature.zope import interfaces, content
+    >>> message = content.ZopeContentFeature()
+    >>> message
+    <ZopeContentFeature u'Zope Content Type (MyContent)'>
+
+The ``ZopeContentFeature`` class implements the
+``IZopeContentFeature`` schema.
+
+    >>> from zope.interface.verify import verifyObject
+    >>> verifyObject(interfaces.IZopeContentFeature, message)
+    True
+
+It also implements the ``IFeature`` interface.
+
+    >>> from z3c.feature.core.interfaces import IFeature
+    >>> verifyObject(IFeature, message)
+    True
+
+Here are some of the ``IFeature`` related attributes.
+
+    >>> print message.featureTitle
+    Zope Content Type (MyContent)
+    >>> print message.featureDocumentation
+    The Zope Content Feature lets you define a basic content type that can
+    be stored in a database and that has a simple page for creating,
+    reading, updating, and deleting the content item.
+
+    >>> message.featureSingleton
+    False
+    >>> message.featureDependencies
+    ()
+
+There are some fields specific to this feature.
+
+    >>> message.className
+    u'MyContent'
+
+Notice that this affects the feature title as well.
+
+    >>> message.className = u"Message"
+    >>> print message.featureTitle
+    Zope Content Type (Message)
+
+Most importantly though, we have the ``fields`` attribute:
+
+    >>> message.fields
+    {}
+
+Let's go ahead and add a few fields:
+
+    >>> import zope.schema
+    >>> message.addField(u'sender','zope.schema.TextLine')
+    >>> message.addField(u'receiver','zope.schema.TextLine')
+    >>> message.addField(u'message','zope.schema.Text')
+
+Now we can apply this to a project.
+
+    >>> from z3c.builder.core.project import BuildoutProjectBuilder
+    >>> demo = BuildoutProjectBuilder(u'demo')
+
+    >>> message.update()
+    >>> message.applyTo(demo)
+
+Now let's take a look at what got added to the project.
+
+    >>> demo.package['interfaces.py']
+    <ModuleBuilder u'interfaces.py'>
+
+    >>> demo.package['interfaces.py'][u'IMessage']
+    <InterfaceBuilder u'IMessage'>
+
+    >>> demo.update()
+    >>> demo.write(buildPath)
+    >>> ls(buildPath)
+    demo/
+      bootstrap.py
+      buildout.cfg
+      setup.py
+      src/
+        demo/
+          __init__.py
+          configure.zcml
+          interfaces.py
+          message.py
+          browser/
+            __init__.py
+            configure.zcml
+            message.py
+
+There is an interfaces.py file with the IMessage interface.
+
+    >>> more(buildPath,'demo','src','demo','interfaces.py')
+    <BLANKLINE>
+    ...
+    from zope.interface import Interface
+    from zope.schema import Text
+    from zope.schema import TextLine
+    <BLANKLINE>
+    class IMessage(Interface):
+        """The ``Message`` Content Type"""
+        message = Text(
+            title=u'Message',
+            )
+    <BLANKLINE>
+        sender = TextLine(
+            title=u'Sender',
+            )
+    <BLANKLINE>
+        receiver = TextLine(
+            title=u'Receiver',
+            )
+
+There is an implementation of the IMessage interface.
+
+    >>> more(buildPath, 'demo','src','demo','message.py')
+    <BLANKLINE>
+    ...
+    from demo.interfaces import IMessage
+    from persistent import Persistent
+    from zope.container.contained import Contained
+    from zope.interface import implements
+    from zope.schema.fieldproperty import FieldProperty
+    <BLANKLINE>
+    class Message(Persistent, Contained):
+        """Implementation of ``demo.interfaces.IMessage``"""
+        implements(IMessage)
+    <BLANKLINE>
+        message = FieldProperty(IMessage['message'])
+        sender = FieldProperty(IMessage['sender'])
+        receiver = FieldProperty(IMessage['receiver'])
+
+    >>> more(buildPath, 'demo','src','demo','configure.zcml')
+    <configure
+        xmlns:zope="http://namespaces.zope.org/zope"
+        i18n_domain="demo"
+        >
+      <zope:class
+          class=".message.Message"
+          >
+        <allow
+            set_schema=".interfaces.IMessage"
+            interface=".interfaces.IMessage"
+            />
+      </zope:class>
+      <zope:include package=".browser" />
+    </configure>
+
+There is configuration for the IMessage implementation.
+
+    >>> more(buildPath,'demo','src','demo','browser','configure.zcml')
+    <configure
+        xmlns:browser="http://namespaces.zope.org/browser"
+        i18n_domain="demo"
+        >
+      <browser:page
+          class="demo.browser.message.MessageAddForm"
+          for="zope.container.interfaces.IContainer"
+          name="index.html"
+          permission="zope.Public"
+          />
+    <BLANKLINE>
+      <browser:page
+          class="demo.browser.message.MessageEditForm"
+          for="demo.interfaces.IMessage"
+          name="edit.html"
+          permission="zope.Public"
+          />
+    <BLANKLINE>
+      <browser:page
+          class="demo.browser.message.MessageDisplayForm"
+          for="demo.interfaces.IMessage"
+          name="index.html"
+          permission="zope.Public"
+          />
+    <BLANKLINE>
+    </configure>
+
+There is a browser package with forms for IMessage.
+
+    >>> more(buildPath, 'demo','src','demo','browser','message.py')
+    <BLANKLINE>
+    ...
+    from demo.interfaces import IMessage
+    from demo.message import Message
+    from z3c.form.field import Fields
+    from z3c.form.form import AddForm
+    from z3c.form.form import DisplayForm
+    from z3c.form.form import EditForm
+    from zope.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+    from zope.traversing.browser import absoluteURL
+    <BLANKLINE>
+    class MessageAddForm(AddForm):
+        """Add form for IMessage"""
+    <BLANKLINE>
+        label = u'Add Form'
+        fields = Fields(IMessage).select('message', 'sender', 'receiver')
+    <BLANKLINE>
+        def create(self, data):
+            object = Message()
+            for name, value in data.items():
+                setattr(object, name, value)
+            return object
+    <BLANKLINE>
+        def add(self, object):
+            count = 0
+            while 'Message-%i' %count in self.context:
+                count += 1;
+            self._name = 'Message-%i' %count
+            self.context[self._name] = object
+            return object
+    <BLANKLINE>
+        def nextURL(self):
+            return absoluteURL(
+                self.context[self._name], self.request) + '/index.html'
+    <BLANKLINE>
+    <BLANKLINE>
+    class MessageEditForm(EditForm):
+        """Edit form for IMessage"""
+    <BLANKLINE>
+        label = u'Edit Form'
+        fields = Fields(IMessage).select('message', 'sender', 'receiver')
+    <BLANKLINE>
+    <BLANKLINE>
+    class MessageDisplayForm(DisplayForm):
+        """Display form for IMessage"""
+        fields = Fields(IMessage).select('message', 'sender', 'receiver')
+
+
+Generating from xml
+-------------------
+
+    >>> feature = content.ZopeContentFeature.fromXML('''\
+    ...     <feature type="z3c.feature.zope:content-type">
+    ...       <className>Message</className>
+    ...       <fields>
+    ...         <field name="receiver" type="zope.schema.TextLine"/>
+    ...         <field name="sender" type="zope.schema.TextLine"/>
+    ...         <field name="message" type="zope.schema.Text"/>
+    ...       </fields>
+    ...     </feature>
+    ... ''')
+
+    >>> feature
+    <ZopeContentFeature u'Zope Content Type (Message)'>
+    >>> feature.fields
+    {u'message': u'zope.schema.Text',
+     u'sender': u'zope.schema.TextLine',
+     u'receiver': u'zope.schema.TextLine'}


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/content.txt
___________________________________________________________________
Added: svn:eol-style
   + native

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/file-templates/simple-page.pt
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/file-templates/simple-page.pt	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/file-templates/simple-page.pt	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,8 @@
+<html>
+  <head>
+    <title>Simple Page</title>
+  </head>
+  <body>
+    <h1>Simple Page</h1>
+  </body>
+</html>


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/file-templates/simple-page.pt
___________________________________________________________________
Added: svn:eol-style
   + native

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/index.txt
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/index.txt	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/index.txt	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,9 @@
+====================
+Zope Boiler Features
+====================
+
+.. toctree::
+   :maxdepth: 2
+
+   README
+   page


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/index.txt
___________________________________________________________________
Added: svn:eol-style
   + native

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/interfaces.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/interfaces.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/interfaces.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,86 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Zope Features Interfaces
+
+$Id$
+"""
+import zope.interface
+import zope.schema
+from zope.schema.vocabulary import SimpleVocabulary
+from zope.schema.vocabulary import SimpleTerm
+
+from z3c.feature.core.interfaces import IFeatureSchema
+
+FieldsVocabulary = SimpleVocabulary(
+    [SimpleTerm('zope.schema.TextLine', u'Text Line', u'Text Line'),
+     SimpleTerm('zope.schema.Text', u'Text', u'Text'),
+     SimpleTerm('zope.schema.Int', u'Integer', u'Integer'),
+     SimpleTerm('zope.schema.Float', u'Float', u'Float'),
+     ])
+
+class IZopeProjectFeature(zope.interface.Interface):
+    """A feature converting a project to a Zope project."""
+zope.interface.directlyProvides(IZopeProjectFeature, IFeatureSchema)
+
+class IZopePageFeature(zope.interface.Interface):
+    """A feature to produce a simple page."""
+
+    name = zope.schema.TextLine(
+        title=u'Name',
+        description=(u'The name by which the page can be accessed in a url '
+                     u'i.e. index.html'),
+        default=u'index.html')
+
+    templateName = zope.schema.TextLine(
+        title=u'Template Name',
+        description=(u'The name of the template for the page. '
+                     u'Defaults to the name of the page.'),
+        required=False)
+
+zope.interface.directlyProvides(IZopePageFeature, IFeatureSchema)
+
+
+class IZopeContentFeature(zope.interface.Interface):
+    """A feature to produce a Content Object with CRUD pages."""
+
+    className = zope.schema.TextLine(
+        title=u'Class Name',
+        description=u'The name of the class to create. i.e. MyContent',
+        default=u'MyContent')
+
+    classFile = zope.schema.TextLine(
+        title=u'Class File',
+        description=(u'The file in which to put the class. i.e. mycontent.py. '
+                     u'Defaults to the lowercased version of the class name'),
+        required=False)
+
+    fields = zope.schema.Dict(
+        title=u'Fields',
+        description=u'The fields for this object',
+        key_type=zope.schema.TextLine(
+            title=u'Name',
+            description=u'The name of the field'),
+        value_type=zope.schema.Choice(
+            title=u'Type',
+            description=u"The field's type.",
+            vocabulary=FieldsVocabulary)
+        )
+
+zope.interface.directlyProvides(IZopeContentFeature, IFeatureSchema)
+
+
+class IZopeSkinFeature(zope.interface.Interface):
+    """A feature to produce a Skin with a layer."""
+
+zope.interface.directlyProvides(IZopeSkinFeature, IFeatureSchema)


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/interfaces.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/project.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/project.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/project.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,212 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Zope Project Feature
+
+$Id$
+"""
+import zope.interface
+from z3c.builder.core import buildout, python, zcml
+from z3c.feature.core import base
+from z3c.feature.zope import interfaces
+
+PROJECT_DOCUMENTATION = u'''
+This feature extends a buildout project to a Zope project.
+'''
+
+class ZopeProjectFeature(base.BaseFeature):
+    zope.interface.implements(interfaces.IZopeProjectFeature)
+
+    featureTitle = u'Zope Project'
+    featureDocumentation = PROJECT_DOCUMENTATION
+
+    def _applyTo(self, project):
+        # Create application ZCML.
+        appConfig = zcml.ZCMLFileBuilder(u'application.zcml')
+        project.package['appConfig'] = appConfig
+
+        for name in ('zope.app.component',
+                     'zope.app.component.browser',
+                     'zope.app.pagetemplate',
+                     'zope.app.publication',
+                     'zope.app.publisher',
+                     'zope.app.security',
+                     'zope.app.securitypolicy',
+                     'zc.configuration',
+                     'z3c.form',
+                     'z3c.template',
+                     'z3c.pagelet',
+                     'z3c.macro',
+                     'zope.viewlet',
+                     ):
+            id = appConfig.add(zcml.ZCMLDirectiveBuilder(
+                namespace = zcml.ZOPE_NS,
+                name = 'include',
+                attributes = {
+                    'package': name,
+                    'file': 'meta.zcml'}
+                ))
+
+        for package, filename in (
+            ('zope.app.securitypolicy.browser', 'configure.zcml'),
+            ('zope.app.session', 'browser.zcml'),
+            ('zope.app.folder.browser', 'configure.zcml'),
+            ):
+            id = appConfig.add(zcml.ZCMLDirectiveBuilder(
+                namespace = zcml.ZOPE_NS,
+                name = 'exclude',
+                attributes = {'package': package, 'file': filename}
+                ))
+
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.BROWSER_NS,
+            name = 'menu',
+            attributes = {
+                'id': 'zmi_views',
+                'title': 'Views'}
+            ))
+
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.BROWSER_NS,
+            name = 'menu',
+            attributes = {
+                'id': 'zmi_actions',
+                'title': 'Actions'}
+            ))
+
+        for name in ('zope.app.appsetup',
+                     'zope.app.component',
+                     'zope.app.container',
+                     'zope.app.error',
+                     'zope.app.i18n',
+                     'zope.app.publication',
+                     'zope.app.security',
+                     'zope.app.securitypolicy',
+                     'zope.app.session',
+                     'zope.app.twisted',
+                     'zope.app.wsgi',
+                     'zope.annotation',
+                     'zope.component',
+                     'zope.container',
+                     'zope.location',
+                     'zope.publisher',
+                     'zope.traversing',
+                     'zope.traversing.browser',
+                     'zope.app.folder',
+                     'z3c.macro',
+                     'z3c.form',
+                     'z3c.formui',
+                     'z3c.pagelet',
+                     'z3c.layer.pagelet',
+                     ):
+            id = appConfig.add(zcml.ZCMLDirectiveBuilder(
+                namespace = zcml.ZOPE_NS,
+                name = 'include',
+                attributes = {'package': name}
+                ))
+
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.ZOPE_NS,
+            name = 'include',
+            attributes = {'package': project.name}
+            ))
+
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.BROWSER_NS,
+            name = 'defaultView',
+            attributes = {
+                'name': 'index.html'}
+            ))
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.ZOPE_NS,
+            name = 'securityPolicy',
+            attributes = {
+                'component': 'zope.securitypolicy.zopepolicy.ZopeSecurityPolicy'}
+            ))
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.ZOPE_NS,
+            name = 'role',
+            attributes = {
+                'id': 'zope.Anonymous',
+                'title': 'Everybody'}
+            ))
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.ZOPE_NS,
+            name = 'grantAll',
+            attributes = {
+                'role': 'zope.Anonymous'}
+            ))
+
+        # Create `browser` package.
+        project.package.add(python.PackageBuilder(u'browser'))
+        project.package['browser'].add(zcml.ZCMLFileBuilder(u'configure.zcml'))
+
+        # Create package configuration file.
+        config = zcml.ZCMLFileBuilder(u'configure.zcml')
+        config.add(zcml.ZCMLDirectiveBuilder(
+            namespace = zcml.ZOPE_NS,
+            name = 'include',
+            attributes = {
+                'package': '.browser'}
+            ))
+        project.package.add(config)
+
+        if 'versions' not in project.buildout.keys():
+            project.buildout.add(buildout.PartBuilder(
+                u'versions',
+                autoBuild=False
+                ))
+        for version in (('zc.configuration','1.0'),
+                        ('z3c.layer.pagelet','1.0.1')):
+            project.buildout['versions'].addValue(*version)
+
+        # Create buildout parts.
+        project.buildout.add(buildout.PartBuilder(
+            u'zope3',
+            [('location', '.')],
+            autoBuild=False
+            ))
+        project.buildout.add(buildout.PartBuilder(
+            u'%s-app' %project.name,
+            [('recipe', 'zc.zope3recipes:app'),
+             ('site.zcml',
+              '<include package="%s" file="application.zcml" />' %project.name),
+             ('eggs', project.name)]
+            ))
+        project.buildout.add(buildout.PartBuilder(
+            project.name,
+            [('recipe', 'zc.zope3recipes:instance'),
+             ('application', '%s-app' %project.name),
+             ('zope.conf', '${database:zconfig}'),
+             ('eggs', project.name)]
+            ))
+        project.buildout.add(buildout.PartBuilder(
+            u'database',
+            [('recipe', 'zc.recipe.filestorage')],
+            autoBuild=False
+            ))
+
+        # Add dependencies.
+        project.setup.install_requires += [
+            'zdaemon',
+            'zc.configuration',
+            'zc.zope3recipes',
+            'zope.app.securitypolicy',
+            'zope.app.container',
+            'zope.app.session',
+            'zope.app.twisted',
+            'zope.container',
+            'z3c.formui',
+            'z3c.pagelet',
+            'z3c.layer.pagelet',
+            ]


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/project.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/skin.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/skin.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/skin.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,78 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Zope skin feature.
+
+$Id$
+"""
+import os
+import zope.interface
+from zope.schema.fieldproperty import FieldProperty
+
+from z3c.builder.core import project, zcml, python, form
+from z3c.feature.core import base, xml
+from z3c.feature.zope import interfaces
+
+SKIN_DOCUMENTATION = """
+The Zope Skin Feature lets you define a basic skin along with a layer
+that can inherit from other layers.
+"""
+
+class ZopeSkinFeature(base.BaseFeature):
+    zope.interface.implements(interfaces.IZopeSkinFeature)
+
+    featureDocumentation = SKIN_DOCUMENTATION
+    featureSingleton = True
+    featureDependencies = ('zope-project',)
+
+    @property
+    def featureTitle(self):
+        return u'Zope Skin'
+
+    def _applyTo(self, project):
+        if 'interfaces.py' not in project.package.keys():
+            project.package.add(python.ModuleBuilder(u'interfaces.py'))
+        ifaces = project.package['interfaces.py']
+
+        # Step 1: define a layer
+        layerIface = python.InterfaceBuilder(u'ILayer')
+        layerIface.docstring = str("Browser Layer for %s" % project.name)
+        layerIface.bases = ['zope.publisher.interfaces.browser.IBrowserRequest']
+        ifaces.add(layerIface)
+
+        # Step 2: define a skin
+        skinIface = python.InterfaceBuilder(u'ISkin')
+        skinIface.docstring = str("Browser Skin for %s" % project.name)
+        skinIface.bases = ['z3c.form.interfaces.IFormLayer',
+                           'z3c.formui.interfaces.IDivFormLayer',
+                           'z3c.layer.pagelet.IPageletBrowserLayer',
+                           layerIface.getPythonPath()]
+        ifaces.add(skinIface)
+
+        configure = project.package['configure']
+
+        # Step 3: register the skin
+        skinDirective = zcml.ZCMLDirectiveBuilder(
+            namespace=zcml.ZOPE_NS,
+            name='interface',
+            attributes={'interface':skinIface.getPythonPath(),
+                        'type':'zope.publisher.interfaces.browser.IBrowserSkinType',
+                        'name':project.name})
+        configure.add(skinDirective)
+
+        # Step 4: make it the default skin
+        appConfig = project.package['appConfig']
+        appConfig.add(zcml.ZCMLDirectiveBuilder(
+            namespace=zcml.BROWSER_NS,
+            name='defaultSkin',
+            attributes={'name':project.name}))


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/skin.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/template.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/template.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/template.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,24 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Zope Project Template
+
+$Id$
+"""
+import os
+from z3c.feature.core import template
+
+ZopeProjectTemplate = template.FileBasedTemplate(
+    os.path.join(os.path.dirname(__file__),"zope-project.xml"),
+    u"Zope 3 Web Application",
+    u"Includes all the features you would want for a Zope 3 Web Application.")


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/template.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/tests.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/tests.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/tests.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,37 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation 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.
+#
+##############################################################################
+"""Test Setup.
+
+$Id$
+"""
+import unittest
+import zope.testing.doctest
+from z3c.builder.core import testing
+
+def test_suite():
+    return unittest.TestSuite((
+
+        zope.testing.doctest.DocFileSuite(
+            'README.txt',
+            setUp=testing.buildSetUp, tearDown=testing.buildTearDown,
+            optionflags=zope.testing.doctest.NORMALIZE_WHITESPACE |
+                        zope.testing.doctest.ELLIPSIS),
+
+        zope.testing.doctest.DocFileSuite(
+            'content.txt',
+            setUp=testing.buildSetUp, tearDown=testing.buildTearDown,
+            optionflags=zope.testing.doctest.NORMALIZE_WHITESPACE |
+                        zope.testing.doctest.ELLIPSIS),
+
+        ))


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/tests.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/web/__init__.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/web/__init__.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/web/__init__.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1 @@
+# Make a package.


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/web/__init__.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/web/content.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/web/content.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/web/content.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,22 @@
+import zope.schema
+from zope.schema.vocabulary import SimpleVocabulary
+from zope.schema.vocabulary import SimpleTerm
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+
+from z3c.form.form import EditForm
+from z3c.form.field import Fields
+from z3c.form.browser.textlines import TextLinesFieldWidget
+from z3c.feature.zope.content import ZopeContentFeature
+from z3c.feature.zope import interfaces
+
+class ZopeContentWebView(EditForm):
+    label = u'Zope Content'
+    fields = Fields(interfaces.IZopeContentFeature).select('className','classFile')
+
+
+class ZopeContentWebFeature(object):
+    viewFactory = ZopeContentWebView
+    contentFactory = ZopeContentFeature
+    title = u"Zope Content"
+    description = (u"Adds a Content Type to zope with forms for adding, "
+                   u"viewing, and editing the content.")


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/web/content.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/web/page.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/web/page.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/web/page.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,21 @@
+import zope.schema
+from zope.schema.vocabulary import SimpleVocabulary
+from zope.schema.vocabulary import SimpleTerm
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+
+from z3c.form.form import EditForm
+from z3c.form.field import Fields
+from z3c.form.browser.textlines import TextLinesFieldWidget
+from z3c.feature.zope.browser import ZopePageFeature
+from z3c.feature.zope import interfaces
+
+class ZopePageWebView(EditForm):
+    label = u'Zope Page'
+    fields = Fields(interfaces.IZopePageFeature)
+
+
+class ZopePageWebFeature(object):
+    viewFactory = ZopePageWebView
+    contentFactory = ZopePageFeature
+    title = u"Zope Page"
+    description = u"Adds a Zope Page."


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/web/page.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/web/project.py
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/web/project.py	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/web/project.py	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,21 @@
+import zope.schema
+from zope.schema.vocabulary import SimpleVocabulary
+from zope.schema.vocabulary import SimpleTerm
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
+
+from z3c.form.form import EditForm
+from z3c.form.field import Fields
+from z3c.form.browser.textlines import TextLinesFieldWidget
+from z3c.feature.zope.project import ZopeProjectFeature
+from z3c.feature.zope import interfaces
+
+class ZopeProjectWebView(EditForm):
+    label = u'Zope Project'
+    fields = Fields(interfaces.IZopeProjectFeature)
+
+
+class ZopeProjectWebFeature(object):
+    viewFactory = ZopeProjectWebView
+    contentFactory = ZopeProjectFeature
+    title = u"Zope Project"
+    description = u"Adds a Zope Project."


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/web/project.py
___________________________________________________________________
Added: svn:keywords
   + Id

Added: z3c.feature.zope/trunk/src/z3c/feature/zope/zope-project.xml
===================================================================
--- z3c.feature.zope/trunk/src/z3c/feature/zope/zope-project.xml	                        (rev 0)
+++ z3c.feature.zope/trunk/src/z3c/feature/zope/zope-project.xml	2009-03-27 08:54:36 UTC (rev 98395)
@@ -0,0 +1,18 @@
+<project name="helloworld">
+  <feature type="z3c.feature.core:meta-data">
+    <author>?</author>
+    <author-email>?</author-email>
+    <description>?</description>
+    <version>?</version>
+    <license>?</license>
+    <url>?</url>
+    <keywords>?</keywords>
+    <namespace-packages>?</namespace-packages>
+    <install-requires>?</install-requires>
+  </feature>
+  <feature type="z3c.feature.core:python-interpreter" />
+  <feature type="z3c.feature.core:unit-testing" />
+  <feature type="z3c.feature.core:documentation" />
+  <feature type="z3c.feature.zope:zope-project" />
+  <feature type="z3c.feature.zope:zope-page" />
+</project>


Property changes on: z3c.feature.zope/trunk/src/z3c/feature/zope/zope-project.xml
___________________________________________________________________
Added: svn:eol-style
   + native



More information about the Checkins mailing list