=======================
z3c.recipe.paster:debug
=======================

This Zope 3 recipes offers a Debug script setup for Zope3 projects.


Options
-------

The 'debug' recipe accepts the following options:

app
  The name of z3c.recipe.paster:serve application section.
  All settings will be taken over from that.
  The ``zope.conf`` generated by that section will be used.


Test
----

Lets define a (bogus) egg 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.exe

We'll create a ``buildout.cfg`` file that defines our paster configuration:

  >>> write('buildout.cfg',
  ... '''
  ... [buildout]
  ... develop = sample
  ... parts = var myapp mydebug
  ...
  ... [var]
  ... recipe = zc.recipe.filestorage
  ...
  ... [myapp]
  ... eggs = sample
  ... recipe = z3c.recipe.paster:serve
  ... ini =
  ...   [app:main]
  ...   use = egg:sample
  ...
  ...   [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 =
  ...   <include package="sample" file="app.zcml" />
  ...
  ... [mydebug]
  ... recipe = z3c.recipe.paster:debug
  ... app=myapp
  ...
  ... ''' % globals())

  >>> ls('bin')
  -  buildout-script.py
  -  buildout.exe

Now, Let's run the buildout and see what we get:

  >>> print system(join('bin', 'buildout')),
  Develop: '/sample-buildout/sample'
  Installing var.
  Installing myapp.
  Generated script '/sample-buildout/bin/myapp'.
  Installing mydebug.
  Generated script '/sample-buildout/bin/mydebug'.

Now check if the setup was correct:

  >>> ls('bin')
  -  buildout-script.py
  -  buildout.exe
  -  myapp-script.py
  -  myapp.exe
  -  mydebug-script.py
  -  mydebug.exe

Check the content of our new generated script.

  >>> cat('bin', 'mydebug')
  <BLANKLINE>
  import sys
  sys.path[0:0] = [
    '/sample-buildout/sample',
    '/sample-pyN.N.egg',
    ...
    '/sample-pyN.N.egg',
    ]
  <BLANKLINE>
  import z3c.recipe.paster.debug
  <BLANKLINE>
  if __name__ == '__main__':
      z3c.recipe.paster.debug.main('/sample-buildout/parts/myapp/zope.conf')
