Package: z3c.recipe.paster
Thez3c.recipe.paster:servegenerates a paste deploy serve scripts and
configuration files for starting a paste deploy based Zope 3 setup. The
paste deploy*.inifile content can get defined in the buildout.cfg file.Note, you have to define an entry_point in your projects setup.py file for
using a application_factory via the section name.Detailed Documentationz3c.recipe.paster:serveThis Zope 3 recipes offers a Paste Deploy setup for Zope3 projects. It requires
to define a Paste Deploy.ini file in the buoldout.cfg. If you need a simple
PasteScript setup you can use the z3c.recipe.paster:paster recipe which allows
to run already existing ``.ini`` files.OptionsThe ‘serve’ recipe accepts the following options:eggsThe names of one or more eggs, with their dependencies that should
be included in the Python path of the generated scripts.iniThe paste deploy*.inifile content.zope.confThe zope.conf file defining the DB used in the WSGI app and the error log
section.site.zcmlThe zope site.zcml file used by the zope application.TestLets define a (bogus) eggs that we can use in our application:>>> mkdir('demo')
>>> write('demo', 'setup.py',
... '''
... from setuptools import setup
... setup(name = 'demo')
... ''')Now check if the setup was correct:>>> ls('bin')
-  buildoutWe’ll create abuildout.cfgfile that defines our paster serve configuration:>>> write('buildout.cfg',
... '''
... [buildout]
... develop = demo
... parts = var myapp
...
... [var]
... recipe = zc.recipe.filestorage
...
... [myapp]
... eggs = demo
... recipe = z3c.recipe.paster:serve
... ini =
...   [app:main]
...   use = egg:demo
...
...   [server:main]
...   use = egg:Paste#http
...   host = 127.0.0.1
...   port = 8080
...
... zope.conf =
...
...   ${var:zconfig}
...
...   <eventlog>
...     <logfile>
...       formatter zope.exceptions.log.Formatter
...       path ${buildout:directory}/parts/myapp/error.log
...     </logfile>
...     <logfile>
...       formatter zope.exceptions.log.Formatter
...       path STDOUT
...     </logfile>
...   </eventlog>
...
...  devmode on
...
... site.zcml =
...   <!-- inlcude other zcml files like principals.zcml or securitypolicy.zcml
...        and your app configuration -->
...   <include package="demo" file="app.zcml" />
...
... ''' % globals())Now, Let’s run the buildout and see what we get:>>> print system(join('bin', 'buildout')),
Develop: '/sample-buildout/demo'
Installing var.
Installing myapp.
Generated script '/sample-buildout/bin/myapp'.The bin folder contains the scripts for serve our new created paste deploy
server:>>> ls('bin')
-  buildout
-  myappCheck the content of our new generated myapp script. As you can see, the
generated script uses thepaste.script.command.runfor starting our server:>>> cat('bin', 'myapp')
#!"C:\Python24\python.exe"
<BLANKLINE>
import sys
sys.path[0:0] = [
  '/sample-buildout/demo',
  '/sample-pyN.N.egg',
  ...
  '/sample-pyN.N.egg',
  ]
<BLANKLINE>
import os
sys.argv[0] = os.path.abspath(sys.argv[0])
<BLANKLINE>
<BLANKLINE>
import paste.script.command
<BLANKLINE>
if __name__ == '__main__':
    paste.script.command.run([
  'serve', '...myapp.ini',
  ]+sys.argv[1:])Thosesample-pyN.N.egglines should be PasteScript and it’s dependencies.Check the content of our new generated myapp.ini file:>>> cat('parts', 'myapp', 'myapp.ini')
<BLANKLINE>
[app:main]
use = egg:demo
[server:main]
use = egg:Paste#http
host = 127.0.0.1
port = 8080Entry pointAs you probably know, there is some magic going on during startup. The sectionapp:mainin the myapp.ini file above must be defined as entry_point in your
projects setup.py file. Without them, theapp:mainisn’t available. You can
define such a app:main entry point using the defaultapplication_factoryoffered from thez3c.recipe.paster.wsgipackage. Of corse you can define
your own application factory if you need to pass some additional configuration
for your app to the factroy defined in your custom*.inifile.The default entry_point offered from the z3c.recipe.paster could be included in
your custom setup.py file like:setup(
    name = 'something',
    version = '0.5.0dev',
    ...
    include_package_data = True,
    package_dir = {'':'src'},
    namespace_packages = [],
    install_requires = [
        'some.package',
        ],
    entry_points = """
        [paste.app_factory]
        main = z3c.recipe.paster.wsgi:application_factory
        """,
)z3c.recipe.paster:pasterThis Zope 3 recipes offers a Paste Deploy script setup for Zope3 projects.The paster part allows us to setup a plain paster executable which could be
used for start up your zope server using the paste deploy “.ini file like:bin/paster serve app.ini. This recipe inherits the zc.recipe.egg class
and will setup the paster within your egg dependency. All you have to do is
to define your eggs. The benefit of this recipe compared with the built in
PasteScript it the option to choose another name if you need more then one
paster script. This is required if you have paster with different egg
dependencies in one buildout configuration.OptionsThe ‘serve’ recipe accepts the following options:eggsThe names of one or more eggs, with their dependencies that should
be included in the Python path of the generated scripts.iniThe paste deploy*.inifile content.zope.confThe zope.conf file defining the DB used in the WSGI app and the error log
section.site.zcmlThe zope site.zcml file used by the zope application.TestLets define a (bogus) eggs that we can use in our application:>>> mkdir('sample')
>>> write('sample', 'setup.py',
... '''
... from setuptools import setup
... setup(name = 'sample')
... ''')Now check if the setup was correct:>>> ls('bin')
-  buildout-script.py
-  buildout.exeWe’ll create abuildout.cfgfile that defines our paster configuration:>>> write('buildout.cfg',
... '''
... [buildout]
... develop = sample
... parts = mypaster
...
... [mypaster]
... recipe = z3c.recipe.paster:paster
... eggs = sample
...
... ''' % globals())>>> ls('bin')
-  buildout-script.py
-  buildout.exeNow, Let’s run the buildout and see what we get:>>> print system(join('bin', 'buildout')),
Develop: '/sample-buildout/sample'
Installing mypaster.
Generated script '/sample-buildout/bin/mypaster'.Now check if the setup was correct:>>> ls('bin')
-  buildout-script.py
-  buildout.exe
-  mypaster-script.py
-  mypaster.exeCheck the content of our new generated paster script. As you can see, the
generated script uses thepaste.script.command.runfor starting our server.
This script is generic but uses the path of our eggs and uses the given name:>>> cat('bin', 'mypaster')
<BLANKLINE>
import sys
sys.path[0:0] = [
  '/sample-buildout/sample',
  '/sample-pyN.N.egg',
  ...
  '/sample-pyN.N.egg',
  ]
<BLANKLINE>
import paste.script.command
<BLANKLINE>
if __name__ == '__main__':
    paste.script.command.run()CHANGES0.5.3 (2010-02-08)Fix: add z3c.recipe.paster egg for debugging if it’s not there to
make sure it’s installed0.5.2 (2010-01-28)Fix: add PasteScript egg if it’s not there to make sure it’s installed0.5.1 (2010-01-22)Addeddebug, an interactive debug prompt.Fixed tests and fix all eggs in test setup.Fixed test normalizer.Updated tests, so they work with current packages.Fixed tests, so they run both an Windows-like and Unix-like OS.0.5.0 (2009-02-22)Initial Release