grokcore.startup


Namegrokcore.startup JSON
Version 4.1 PyPI version JSON
download
home_pagehttps://github.com/zopefoundation/grokcore.startup
SummaryPaster support for Grok projects.
upload_time2024-05-22 15:41:45
maintainerNone
docs_urlNone
authorGrok Team
requires_python>=3.7
licenseZPL
keywords zope zope3 grok grokproject wsgi paste paster
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            grokcore.startup
****************

This package provides elements for starting a `Grok`_ project with
`paster`_ and `WSGI`_.

.. contents::

Setting up ``grokcore.startup``
===============================

There is nothing special to setup this package.

All you have to do is, to make this package available during runtime.

With `zc.buildout`_ or other `setuptools`_-related setups this can be
done by simply adding the package name ``grokcore.startup`` to the
required packages of your project in ``setup.py``.


Detailed Description
********************

Setting up Grok projects as ``paster`` served WSGI applications
===============================================================

The main target of this package is to provide support for enabling
`Grok`_ applications to be run as `paster`_ served `WSGI`_
applications. To make this working some configuration files have to be
set up.

Setting up a project with ``grokproject``
-----------------------------------------

The most convenient way to setup a `Grok`_ project is using
`grokproject`_. Once installed, you can a project like this::

  $ grokproject Sample

which will generate all configuration files for you.

.. note:: Older versions of `grokproject`_ need an update

  As older versions of `grokproject`_ do not support
  `grokcore.startup`, you might want to update your existing
  `grokproject`_ installation by running::

    $ easy_install -U grokproject


Setting up a project manually
-----------------------------

Before we can make use of ``grokcore.startup``, we have to setup
several configuration files in the project root:

* ``setup.py``

* ``buildout.cfg`` (optional)

* ``zope.conf`` (normally found in the ``parts/etc/`` subdirectory of your
  `Grok`_ project)

* ``site.zcml`` (normally found in the ``parts/etc/`` subdirectory of your
  `Grok`_ project)

* ``deploy.ini`` (or any other .ini-file; normally found in the
  ``parts/etc/`` subdirectory of your `Grok`_ project)


When we want to setup a Zope instance as `paster`_ served `WSGI`_
application, then we have to set a ``paste.app_factory`` entry point
in ``setup.py``. A minimal setup could look like this::

  # setup.py
  from setuptools import setup, find_packages

  setup(name='sampleproject',
        version='0.1dev',
        description="A sample project",
        long_description="""Without a long description.""",
        classifiers=[],
        keywords="",
        author="U.N.Owen",
        author_email="",
        url="",
        license="",
        package_dir={'': 'src'},
        packages=find_packages('src'),
        include_package_data=True,
        zip_safe=False,
        install_requires=['setuptools',],
        entry_points = """
        [paste.app_factory]
        main = grokcore.startup:application_factory
        """,
        )

Here the `paste.app_factory` entry point pointing to
`grokcore.startup:application_factory` is important.

Furthermore we need at least a minimal ``buildout.cfg`` which enables
`zc.buildout`_ to create the control scripts for our instance::

  [buildout]
  develop = .
  parts = app

  [app]
  recipe = zc.recipe.egg
  eggs = sampleproject
         grokcore.startup
         Paste
         PasteScript
         PasteDeploy

Here an egg-entry for ``grokcore.startup`` **might** be important, if
it is not required otherwise by your application. Projects generated
by `grokproject`_ will automatically include such a dependency and
upcoming versions of `Grok`_ will pull in ``grokcore.startup`` anyway,
so that ``grokcore.startup`` would not be required in this list of
eggs any more.

Next we need ``site.zcml`` and ``zope.conf`` files to define the
Zope instance. These configurations are completely independent from
being served by `Paste`_ or not. If you are upgrading an old `Grok`_
project, you can use ``site.zcml`` and ``zope.conf`` of those project
as-is. You only have to take care of the maybe changed
``site-definition`` entry in ``zope.conf`` (see below).

The file ``site.zcml`` can be quite
short, but for real projects you certainly want to have some useful
content in here::

  <configure />

A short ``zope.conf`` file for use in tests could look like this::

  site-definition site.zcml

  <zodb>
    <mappingstorage />
  </zodb>

  <eventlog>
    <logfile>
      path STDOUT
     </logfile>
  </eventlog>

where the ``site-definition`` entry should point to the location of
the file ``site.zcml``. In regular Grok projects those files are put
into the ``etc/`` subdirectory of your project root.

Finally we have to provide a ``deploy.ini`` (or another .ini-file),
which tells paster where to find the pieces. This is also put into the
``etc/`` subdirectory of your project root in regular Grok projects
created by `grokproject`_::

  [app:main]
  use = egg:sampleproject

  [server:main]
  use = egg:Paste#http
  host = 127.0.0.1
  port = 8080

  [DEFAULT]
  zope_conf = %(here)s/zope.conf



API Documentation
=================

``application_factory(global_conf, **local_conf)``
--------------------------------------------------

  ``grokcore.startup`` provides a function ``application_factory``
  which delivers a `WSGIPublisherApplication`_ instance when called
  with an appropriate configuration. See the `zope.app.wsgi
  documentation
  <http://apidoc.zope.org/++apidoc++/Code/zope/app/wsgi/README.txt/index.html>`_
  to learn more about Zope objects supporting `WSGI`_.

  A call to this function is normally required as entry point in
  `setuptools`_-driven `paster`_ environments  (see
  http://pythonpaste.org/deploy/#paste-app-factory).

  We have to create our own site definition file -- which will simply
  be empty -- to provide a minimal test::

    >>> import os, tempfile
    >>> temp_dir = tempfile.mkdtemp()
    >>> sitezcml = os.path.join(temp_dir, 'site.zcml')
    >>> out = open(sitezcml, 'w')
    >>> _ = out.write('<configure />')
    >>> out.close()

  Furthermore we create a Zope configuration file, which is also quite
  plain::

    >>> zope_conf = os.path.join(temp_dir, 'zope.conf')
    >>> out = open(zope_conf, 'w')
    >>> _ = out.write('''
    ... site-definition %s
    ...
    ... <zodb>
    ...   <mappingstorage />
    ... </zodb>
    ...
    ... <eventlog>
    ...   <logfile>
    ...     path STDOUT
    ...   </logfile>
    ... </eventlog>
    ... ''' % sitezcml)
    >>> out.close()

  Now we can call ``application_factory`` to get a WSGI application::

    >>> from grokcore.startup import application_factory
    >>> app_factory = application_factory({'zope_conf': zope_conf})
    >>> app_factory
    <zope.app.wsgi.WSGIPublisherApplication object at 0x...>

``debug_application_factory(global_conf, **local_conf)``
--------------------------------------------------------

  There's a second application factory that can be used when debugging
  the application, especially when using the ``z3c.evalexception`` middleware.

  When debugging zope is instructed not to handle any raised exceptions
  itself. The ``z3c.evalexception`` middleware then catches the exceptions
  and provides an user interfaces for debugging in the webbrowser.

  As a result also the IUnauthorized execption would not be handled by zope
  and the authentication mechanisms of zope are not triggered. As a result,
  when debugging one cannot login.

  The ``debug_application_factory`` function accepts the "exempt-exceptions"
  configuration option. The value for this option should be a comma seperated
  list of dotted names for each of the execptions that should *still* be
  handled by zope and not re-raised to be catched by the middleware.

    >>> from grokcore.startup import debug_application_factory
    >>> app_factory = debug_application_factory({'zope_conf': zope_conf})
    >>> app_factory
    <zope.app.wsgi.WSGIPublisherApplication object at 0x...>

    >>> from zope.interface import implementer
    >>> from zope.security.interfaces import IUnauthorized
    >>> @implementer(IUnauthorized)
    ... class UnauthorizedException(object):
    ...     pass
    >>>
    >>> from zope.component import queryAdapter
    >>> from zope.publisher.interfaces import IReRaiseException

  Since the ``exempt-execptions`` configuration option was not passed,
  there's no IReRaiseException adapter registered for any type of exceptions
  including IUnauthorized:

    >>> error = UnauthorizedException()
    >>> reraise = queryAdapter(error, IReRaiseException, default=None)
    >>> reraise is None
    True

  When the option is passed, the adapter will be registered. Calling this
  adapter yields ``False``, telling zope not to reraise this particular
  exception.

    >>> app_factory = debug_application_factory(
    ...     {'zope_conf': zope_conf},
    ...     **{'exempt-exceptions': 'zope.security.interfaces.IUnauthorized'})
    >>>
    >>> reraise = queryAdapter(error, IReRaiseException, default=None)
    >>> reraise is None
    False
    >>> reraise()
    False

  Clean up the temp_dir

    >>> import shutil
    >>> shutil.rmtree(temp_dir)

``interactive_debug_prompt(zope_conf_path)``
--------------------------------------------

  Get an interactive console with a debugging shell started.

  `grokcore.startup` provides two different debuggers currently: a
  plain one based on `zope.app.debug` and a more powerful `IPython`_
  debugger. The IPython debugger is automatically enabled if you have
  IPython available in the environment.

  You can explicitly enable the IPython_ debugger by stating::

    grokcore.startup [debug]

  in the install requirements of your `setup.py`, probably adding only
  ``[debug]`` to an already existing entry for
  `grokcore.startup`. Don't forget to rerun `buildout` afterwards.

  You can explicitly require one or the other debugger by calling::

    grokcore.startup.startup.interactive_debug_prompt(zope_conf)

  or::

    grokcore.startup.debug.ipython_debug_prompt(zope_conf)

  in the ``[interactive_debugger]`` section of your ``buildout.cfg``.

    >>> import zope.app.appsetup.appsetup
    >>> zope.app.appsetup.appsetup._configured = False

    >>> temp_dir = tempfile.mkdtemp()

    >>> sitezcml = os.path.join(temp_dir, 'site.zcml')
    >>> out = open(sitezcml, 'w')
    >>> _ = out.write(
    ...    """<configure xmlns="http://namespaces.zope.org/zope">
    ...   <include package="zope.component" file="meta.zcml"/>
    ...   <include package="zope.component"/>
    ...   <include package="zope.traversing"/>
    ...   <include package="zope.security" file="meta.zcml"/>
    ...   <include package="zope.security"/>
    ...   <include package="zope.container"/>
    ...   <include package="zope.site"/>
    ...   <include package="zope.app.appsetup"/>
    ... </configure>""")
    >>> out.close()
    >>>
    >>> zopeconf = os.path.join(temp_dir, 'zope.conf')
    >>> out = open(zopeconf, 'w')
    >>> _ = out.write("""
    ...     site-definition %s
    ...     <zodb>
    ...       <filestorage>
    ...         path %s
    ...       </filestorage>
    ...     </zodb>
    ...     <eventlog>
    ...       <logfile>
    ...         path STDOUT
    ...         formatter zope.exceptions.log.Formatter
    ...       </logfile>
    ...     </eventlog>
    ...     """ % (sitezcml, os.path.join(temp_dir, 'Data.fs')))
    >>> out.close()
    >>>
    >>> import sys
    >>> old_argv = sys.argv[:]
    >>>
    >>> script = os.path.join(temp_dir, 'script.py')
    >>> out = open(script, 'w')
    >>> _ = out.write(
    ...    """import sys
    ... from pprint import pprint
    ... pprint(debugger)
    ... pprint(app)
    ... pprint(root)
    ... pprint(sys.argv)
    ... pprint(__file__)
    ... pprint(__name__)""")
    >>>
    >>> out.close()
    >>>
    >>> sys.argv = ['interactive_debugger', script]
    >>> from grokcore.startup import interactive_debug_prompt
    >>> try:
    ...     interactive_debug_prompt(zopeconf)
    ... except SystemExit:
    ...     # Catch the exit from the interactive prompt as it would
    ...     # exit this test as well.
    ...     pass
    ------
    ...WARNING zope.app.appsetup Security policy is not configured.
    Please make sure that securitypolicy.zcml is included in site.zcml
    immediately before principals.zcml
    ...
    <zope.app.debug.debug.Debugger object at ...>
    <zope.app.debug.debug.Debugger object at ...>
    <zope.site.folder.Folder object at ...>
    ['...script.py']
    '...script.py'
    '__main__'

  Clean up the temp_dir

    >>> sys.argv = old_argv
    >>> import shutil
    >>> shutil.rmtree(temp_dir)

.. _grok: http://pypi.python.org/pypi/grok
.. _grokproject: http://pypi.python.org/pypi/grokproject
.. _Paste: http://pythonpaste.org/
.. _paster: Paste_
.. _setuptools: http://pypi.python.org/pypi/setuptools
.. _WSGI: http://www.wsgi.org/wsgi/
.. _WSGIPublisherApplication: http://apidoc.zope.org/++apidoc++/Code/zope/app/wsgi/WSGIPublisherApplication/index.html
.. _zc.buildout: http://pypi.python.org/pypi/zc.buildout
.. _ipython: http://ipython.org/

Changes
*******

4.1 (2024-05-22)
================

- Add support for Python 3.12.

- Update ``debug.py`` to run with ``IPython >= 8``. Also requiring at least
  that version of IPython.


4.0 (2023-07-14)
================

- Drop support for Python 2.7, 3.4, 3.5, 3.6.

- Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11.


3.0.1 (2018-01-12)
==================

- Rearrange tests such that Travis CI can pick up all functional tests too.

3.0.0 (2018-01-10)
==================

- Python 3 compatibility.

1.2.1 (2016-02-15)
==================

- Update tests.

1.2 (2012-05-02)
================

- Added new IPython-based interactive debugger which is used
  automatically when IPython is available. Otherwise the gdb-style
  debugger is provided.

1.1 (2010-10-26)
================

- Drop zdaemon support.

- Close the database explicitely when execing a script through the
  ``interactive_debug_prompt``. This came to light in tests on Windows, as the
  tests would try to delete the temp directory it created with the still
  unclosed database file in there.

1.0.2 (2010-10-05)
==================

- Somehow the intended fix in 1.0.1 did not actually get included in that
  release. We make the fix again.

1.0.1 (2010-08-18)
==================

- When passing a script to the interactive_debug_prompt command, one would
  expect to be able to do: `if __name__ == '__main__':`, however __name__ would
  be "__builtin__". This is fixed.

1.0 (2010-05-20)
================

- Amend the interactive_debug_prompt function to behave more or less like the
  "old" zopectl command. Whenever there's commandline arguments passed to the
  command, the first one is assumed to be a python script that is 'execfile'd.
  This allows ad hoc scripts to run against the setup application.

- Make package comply to zope.org repository policy.

- The upgrade notes will be moved to the Grok upgrade notes.

- Define entry points for main and debug application factories in
  grokcore.startup.

- Use the groktoolkit.

0.4 (2009-10-06)
================

- Fix documentation bugs.

0.3 (2009-10-02)
================

* Add a ``debug_application_factory`` function that allows for the
  ``exempt-exceptions`` configuration option. The value for this option
  should be a comma seperated list of dotted names for each of the exceptions
  that should not be re-raised during debugging.

  This for one allow the IUnauthorized exception to still be handled by zope
  and thus have the normal authentication mechanisms still work.

* Bring versions.cfg in line with current grok versions.cfg.

0.2 (2009-02-21)
================

* Made main functions available package wide.

0.1 (2009-01-15)
================

* Added support for local ``zope_conf`` parameter.
  Fix bug https://bugs.launchpad.net/grok/+bug/320644

* Created ``grokcore.startup`` in January 2009 by factoring paster
  related application code out of grokcore templates.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zopefoundation/grokcore.startup",
    "name": "grokcore.startup",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "zope zope3 grok grokproject WSGI Paste paster",
    "author": "Grok Team",
    "author_email": "zope-dev@zope.dev",
    "download_url": "https://files.pythonhosted.org/packages/92/b0/8904e6a59df59bd9fa1beb35b1cb74f4cb9425f9ab974e096f45fc0a5b36/grokcore.startup-4.1.tar.gz",
    "platform": null,
    "description": "grokcore.startup\n****************\n\nThis package provides elements for starting a `Grok`_ project with\n`paster`_ and `WSGI`_.\n\n.. contents::\n\nSetting up ``grokcore.startup``\n===============================\n\nThere is nothing special to setup this package.\n\nAll you have to do is, to make this package available during runtime.\n\nWith `zc.buildout`_ or other `setuptools`_-related setups this can be\ndone by simply adding the package name ``grokcore.startup`` to the\nrequired packages of your project in ``setup.py``.\n\n\nDetailed Description\n********************\n\nSetting up Grok projects as ``paster`` served WSGI applications\n===============================================================\n\nThe main target of this package is to provide support for enabling\n`Grok`_ applications to be run as `paster`_ served `WSGI`_\napplications. To make this working some configuration files have to be\nset up.\n\nSetting up a project with ``grokproject``\n-----------------------------------------\n\nThe most convenient way to setup a `Grok`_ project is using\n`grokproject`_. Once installed, you can a project like this::\n\n  $ grokproject Sample\n\nwhich will generate all configuration files for you.\n\n.. note:: Older versions of `grokproject`_ need an update\n\n  As older versions of `grokproject`_ do not support\n  `grokcore.startup`, you might want to update your existing\n  `grokproject`_ installation by running::\n\n    $ easy_install -U grokproject\n\n\nSetting up a project manually\n-----------------------------\n\nBefore we can make use of ``grokcore.startup``, we have to setup\nseveral configuration files in the project root:\n\n* ``setup.py``\n\n* ``buildout.cfg`` (optional)\n\n* ``zope.conf`` (normally found in the ``parts/etc/`` subdirectory of your\n  `Grok`_ project)\n\n* ``site.zcml`` (normally found in the ``parts/etc/`` subdirectory of your\n  `Grok`_ project)\n\n* ``deploy.ini`` (or any other .ini-file; normally found in the\n  ``parts/etc/`` subdirectory of your `Grok`_ project)\n\n\nWhen we want to setup a Zope instance as `paster`_ served `WSGI`_\napplication, then we have to set a ``paste.app_factory`` entry point\nin ``setup.py``. A minimal setup could look like this::\n\n  # setup.py\n  from setuptools import setup, find_packages\n\n  setup(name='sampleproject',\n        version='0.1dev',\n        description=\"A sample project\",\n        long_description=\"\"\"Without a long description.\"\"\",\n        classifiers=[],\n        keywords=\"\",\n        author=\"U.N.Owen\",\n        author_email=\"\",\n        url=\"\",\n        license=\"\",\n        package_dir={'': 'src'},\n        packages=find_packages('src'),\n        include_package_data=True,\n        zip_safe=False,\n        install_requires=['setuptools',],\n        entry_points = \"\"\"\n        [paste.app_factory]\n        main = grokcore.startup:application_factory\n        \"\"\",\n        )\n\nHere the `paste.app_factory` entry point pointing to\n`grokcore.startup:application_factory` is important.\n\nFurthermore we need at least a minimal ``buildout.cfg`` which enables\n`zc.buildout`_ to create the control scripts for our instance::\n\n  [buildout]\n  develop = .\n  parts = app\n\n  [app]\n  recipe = zc.recipe.egg\n  eggs = sampleproject\n         grokcore.startup\n         Paste\n         PasteScript\n         PasteDeploy\n\nHere an egg-entry for ``grokcore.startup`` **might** be important, if\nit is not required otherwise by your application. Projects generated\nby `grokproject`_ will automatically include such a dependency and\nupcoming versions of `Grok`_ will pull in ``grokcore.startup`` anyway,\nso that ``grokcore.startup`` would not be required in this list of\neggs any more.\n\nNext we need ``site.zcml`` and ``zope.conf`` files to define the\nZope instance. These configurations are completely independent from\nbeing served by `Paste`_ or not. If you are upgrading an old `Grok`_\nproject, you can use ``site.zcml`` and ``zope.conf`` of those project\nas-is. You only have to take care of the maybe changed\n``site-definition`` entry in ``zope.conf`` (see below).\n\nThe file ``site.zcml`` can be quite\nshort, but for real projects you certainly want to have some useful\ncontent in here::\n\n  <configure />\n\nA short ``zope.conf`` file for use in tests could look like this::\n\n  site-definition site.zcml\n\n  <zodb>\n    <mappingstorage />\n  </zodb>\n\n  <eventlog>\n    <logfile>\n      path STDOUT\n     </logfile>\n  </eventlog>\n\nwhere the ``site-definition`` entry should point to the location of\nthe file ``site.zcml``. In regular Grok projects those files are put\ninto the ``etc/`` subdirectory of your project root.\n\nFinally we have to provide a ``deploy.ini`` (or another .ini-file),\nwhich tells paster where to find the pieces. This is also put into the\n``etc/`` subdirectory of your project root in regular Grok projects\ncreated by `grokproject`_::\n\n  [app:main]\n  use = egg:sampleproject\n\n  [server:main]\n  use = egg:Paste#http\n  host = 127.0.0.1\n  port = 8080\n\n  [DEFAULT]\n  zope_conf = %(here)s/zope.conf\n\n\n\nAPI Documentation\n=================\n\n``application_factory(global_conf, **local_conf)``\n--------------------------------------------------\n\n  ``grokcore.startup`` provides a function ``application_factory``\n  which delivers a `WSGIPublisherApplication`_ instance when called\n  with an appropriate configuration. See the `zope.app.wsgi\n  documentation\n  <http://apidoc.zope.org/++apidoc++/Code/zope/app/wsgi/README.txt/index.html>`_\n  to learn more about Zope objects supporting `WSGI`_.\n\n  A call to this function is normally required as entry point in\n  `setuptools`_-driven `paster`_ environments  (see\n  http://pythonpaste.org/deploy/#paste-app-factory).\n\n  We have to create our own site definition file -- which will simply\n  be empty -- to provide a minimal test::\n\n    >>> import os, tempfile\n    >>> temp_dir = tempfile.mkdtemp()\n    >>> sitezcml = os.path.join(temp_dir, 'site.zcml')\n    >>> out = open(sitezcml, 'w')\n    >>> _ = out.write('<configure />')\n    >>> out.close()\n\n  Furthermore we create a Zope configuration file, which is also quite\n  plain::\n\n    >>> zope_conf = os.path.join(temp_dir, 'zope.conf')\n    >>> out = open(zope_conf, 'w')\n    >>> _ = out.write('''\n    ... site-definition %s\n    ...\n    ... <zodb>\n    ...   <mappingstorage />\n    ... </zodb>\n    ...\n    ... <eventlog>\n    ...   <logfile>\n    ...     path STDOUT\n    ...   </logfile>\n    ... </eventlog>\n    ... ''' % sitezcml)\n    >>> out.close()\n\n  Now we can call ``application_factory`` to get a WSGI application::\n\n    >>> from grokcore.startup import application_factory\n    >>> app_factory = application_factory({'zope_conf': zope_conf})\n    >>> app_factory\n    <zope.app.wsgi.WSGIPublisherApplication object at 0x...>\n\n``debug_application_factory(global_conf, **local_conf)``\n--------------------------------------------------------\n\n  There's a second application factory that can be used when debugging\n  the application, especially when using the ``z3c.evalexception`` middleware.\n\n  When debugging zope is instructed not to handle any raised exceptions\n  itself. The ``z3c.evalexception`` middleware then catches the exceptions\n  and provides an user interfaces for debugging in the webbrowser.\n\n  As a result also the IUnauthorized execption would not be handled by zope\n  and the authentication mechanisms of zope are not triggered. As a result,\n  when debugging one cannot login.\n\n  The ``debug_application_factory`` function accepts the \"exempt-exceptions\"\n  configuration option. The value for this option should be a comma seperated\n  list of dotted names for each of the execptions that should *still* be\n  handled by zope and not re-raised to be catched by the middleware.\n\n    >>> from grokcore.startup import debug_application_factory\n    >>> app_factory = debug_application_factory({'zope_conf': zope_conf})\n    >>> app_factory\n    <zope.app.wsgi.WSGIPublisherApplication object at 0x...>\n\n    >>> from zope.interface import implementer\n    >>> from zope.security.interfaces import IUnauthorized\n    >>> @implementer(IUnauthorized)\n    ... class UnauthorizedException(object):\n    ...     pass\n    >>>\n    >>> from zope.component import queryAdapter\n    >>> from zope.publisher.interfaces import IReRaiseException\n\n  Since the ``exempt-execptions`` configuration option was not passed,\n  there's no IReRaiseException adapter registered for any type of exceptions\n  including IUnauthorized:\n\n    >>> error = UnauthorizedException()\n    >>> reraise = queryAdapter(error, IReRaiseException, default=None)\n    >>> reraise is None\n    True\n\n  When the option is passed, the adapter will be registered. Calling this\n  adapter yields ``False``, telling zope not to reraise this particular\n  exception.\n\n    >>> app_factory = debug_application_factory(\n    ...     {'zope_conf': zope_conf},\n    ...     **{'exempt-exceptions': 'zope.security.interfaces.IUnauthorized'})\n    >>>\n    >>> reraise = queryAdapter(error, IReRaiseException, default=None)\n    >>> reraise is None\n    False\n    >>> reraise()\n    False\n\n  Clean up the temp_dir\n\n    >>> import shutil\n    >>> shutil.rmtree(temp_dir)\n\n``interactive_debug_prompt(zope_conf_path)``\n--------------------------------------------\n\n  Get an interactive console with a debugging shell started.\n\n  `grokcore.startup` provides two different debuggers currently: a\n  plain one based on `zope.app.debug` and a more powerful `IPython`_\n  debugger. The IPython debugger is automatically enabled if you have\n  IPython available in the environment.\n\n  You can explicitly enable the IPython_ debugger by stating::\n\n    grokcore.startup [debug]\n\n  in the install requirements of your `setup.py`, probably adding only\n  ``[debug]`` to an already existing entry for\n  `grokcore.startup`. Don't forget to rerun `buildout` afterwards.\n\n  You can explicitly require one or the other debugger by calling::\n\n    grokcore.startup.startup.interactive_debug_prompt(zope_conf)\n\n  or::\n\n    grokcore.startup.debug.ipython_debug_prompt(zope_conf)\n\n  in the ``[interactive_debugger]`` section of your ``buildout.cfg``.\n\n    >>> import zope.app.appsetup.appsetup\n    >>> zope.app.appsetup.appsetup._configured = False\n\n    >>> temp_dir = tempfile.mkdtemp()\n\n    >>> sitezcml = os.path.join(temp_dir, 'site.zcml')\n    >>> out = open(sitezcml, 'w')\n    >>> _ = out.write(\n    ...    \"\"\"<configure xmlns=\"http://namespaces.zope.org/zope\">\n    ...   <include package=\"zope.component\" file=\"meta.zcml\"/>\n    ...   <include package=\"zope.component\"/>\n    ...   <include package=\"zope.traversing\"/>\n    ...   <include package=\"zope.security\" file=\"meta.zcml\"/>\n    ...   <include package=\"zope.security\"/>\n    ...   <include package=\"zope.container\"/>\n    ...   <include package=\"zope.site\"/>\n    ...   <include package=\"zope.app.appsetup\"/>\n    ... </configure>\"\"\")\n    >>> out.close()\n    >>>\n    >>> zopeconf = os.path.join(temp_dir, 'zope.conf')\n    >>> out = open(zopeconf, 'w')\n    >>> _ = out.write(\"\"\"\n    ...     site-definition %s\n    ...     <zodb>\n    ...       <filestorage>\n    ...         path %s\n    ...       </filestorage>\n    ...     </zodb>\n    ...     <eventlog>\n    ...       <logfile>\n    ...         path STDOUT\n    ...         formatter zope.exceptions.log.Formatter\n    ...       </logfile>\n    ...     </eventlog>\n    ...     \"\"\" % (sitezcml, os.path.join(temp_dir, 'Data.fs')))\n    >>> out.close()\n    >>>\n    >>> import sys\n    >>> old_argv = sys.argv[:]\n    >>>\n    >>> script = os.path.join(temp_dir, 'script.py')\n    >>> out = open(script, 'w')\n    >>> _ = out.write(\n    ...    \"\"\"import sys\n    ... from pprint import pprint\n    ... pprint(debugger)\n    ... pprint(app)\n    ... pprint(root)\n    ... pprint(sys.argv)\n    ... pprint(__file__)\n    ... pprint(__name__)\"\"\")\n    >>>\n    >>> out.close()\n    >>>\n    >>> sys.argv = ['interactive_debugger', script]\n    >>> from grokcore.startup import interactive_debug_prompt\n    >>> try:\n    ...     interactive_debug_prompt(zopeconf)\n    ... except SystemExit:\n    ...     # Catch the exit from the interactive prompt as it would\n    ...     # exit this test as well.\n    ...     pass\n    ------\n    ...WARNING zope.app.appsetup Security policy is not configured.\n    Please make sure that securitypolicy.zcml is included in site.zcml\n    immediately before principals.zcml\n    ...\n    <zope.app.debug.debug.Debugger object at ...>\n    <zope.app.debug.debug.Debugger object at ...>\n    <zope.site.folder.Folder object at ...>\n    ['...script.py']\n    '...script.py'\n    '__main__'\n\n  Clean up the temp_dir\n\n    >>> sys.argv = old_argv\n    >>> import shutil\n    >>> shutil.rmtree(temp_dir)\n\n.. _grok: http://pypi.python.org/pypi/grok\n.. _grokproject: http://pypi.python.org/pypi/grokproject\n.. _Paste: http://pythonpaste.org/\n.. _paster: Paste_\n.. _setuptools: http://pypi.python.org/pypi/setuptools\n.. _WSGI: http://www.wsgi.org/wsgi/\n.. _WSGIPublisherApplication: http://apidoc.zope.org/++apidoc++/Code/zope/app/wsgi/WSGIPublisherApplication/index.html\n.. _zc.buildout: http://pypi.python.org/pypi/zc.buildout\n.. _ipython: http://ipython.org/\n\nChanges\n*******\n\n4.1 (2024-05-22)\n================\n\n- Add support for Python 3.12.\n\n- Update ``debug.py`` to run with ``IPython >= 8``. Also requiring at least\n  that version of IPython.\n\n\n4.0 (2023-07-14)\n================\n\n- Drop support for Python 2.7, 3.4, 3.5, 3.6.\n\n- Add support for Python 3.7, 3.8, 3.9, 3.10, 3.11.\n\n\n3.0.1 (2018-01-12)\n==================\n\n- Rearrange tests such that Travis CI can pick up all functional tests too.\n\n3.0.0 (2018-01-10)\n==================\n\n- Python 3 compatibility.\n\n1.2.1 (2016-02-15)\n==================\n\n- Update tests.\n\n1.2 (2012-05-02)\n================\n\n- Added new IPython-based interactive debugger which is used\n  automatically when IPython is available. Otherwise the gdb-style\n  debugger is provided.\n\n1.1 (2010-10-26)\n================\n\n- Drop zdaemon support.\n\n- Close the database explicitely when execing a script through the\n  ``interactive_debug_prompt``. This came to light in tests on Windows, as the\n  tests would try to delete the temp directory it created with the still\n  unclosed database file in there.\n\n1.0.2 (2010-10-05)\n==================\n\n- Somehow the intended fix in 1.0.1 did not actually get included in that\n  release. We make the fix again.\n\n1.0.1 (2010-08-18)\n==================\n\n- When passing a script to the interactive_debug_prompt command, one would\n  expect to be able to do: `if __name__ == '__main__':`, however __name__ would\n  be \"__builtin__\". This is fixed.\n\n1.0 (2010-05-20)\n================\n\n- Amend the interactive_debug_prompt function to behave more or less like the\n  \"old\" zopectl command. Whenever there's commandline arguments passed to the\n  command, the first one is assumed to be a python script that is 'execfile'd.\n  This allows ad hoc scripts to run against the setup application.\n\n- Make package comply to zope.org repository policy.\n\n- The upgrade notes will be moved to the Grok upgrade notes.\n\n- Define entry points for main and debug application factories in\n  grokcore.startup.\n\n- Use the groktoolkit.\n\n0.4 (2009-10-06)\n================\n\n- Fix documentation bugs.\n\n0.3 (2009-10-02)\n================\n\n* Add a ``debug_application_factory`` function that allows for the\n  ``exempt-exceptions`` configuration option. The value for this option\n  should be a comma seperated list of dotted names for each of the exceptions\n  that should not be re-raised during debugging.\n\n  This for one allow the IUnauthorized exception to still be handled by zope\n  and thus have the normal authentication mechanisms still work.\n\n* Bring versions.cfg in line with current grok versions.cfg.\n\n0.2 (2009-02-21)\n================\n\n* Made main functions available package wide.\n\n0.1 (2009-01-15)\n================\n\n* Added support for local ``zope_conf`` parameter.\n  Fix bug https://bugs.launchpad.net/grok/+bug/320644\n\n* Created ``grokcore.startup`` in January 2009 by factoring paster\n  related application code out of grokcore templates.\n",
    "bugtrack_url": null,
    "license": "ZPL",
    "summary": "Paster support for Grok projects.",
    "version": "4.1",
    "project_urls": {
        "Homepage": "https://github.com/zopefoundation/grokcore.startup"
    },
    "split_keywords": [
        "zope",
        "zope3",
        "grok",
        "grokproject",
        "wsgi",
        "paste",
        "paster"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ce1b11a6e1ea7a717405385bdaa563df9962d11bd5136a70e28ac97e2589e731",
                "md5": "af014cfc781640bdf8ddfa74c1e817da",
                "sha256": "5446fb2519ea4f84c2a9b45cabd31425b18ddbede48d76d98228f9dd7ebb588d"
            },
            "downloads": -1,
            "filename": "grokcore.startup-4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "af014cfc781640bdf8ddfa74c1e817da",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 17602,
            "upload_time": "2024-05-22T15:41:41",
            "upload_time_iso_8601": "2024-05-22T15:41:41.012349Z",
            "url": "https://files.pythonhosted.org/packages/ce/1b/11a6e1ea7a717405385bdaa563df9962d11bd5136a70e28ac97e2589e731/grokcore.startup-4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92b08904e6a59df59bd9fa1beb35b1cb74f4cb9425f9ab974e096f45fc0a5b36",
                "md5": "19203c3bf622dfac2f8b6f757bd3afc6",
                "sha256": "b69f2bce2b54c522fa2c3705d73b59c1a9eeeb10642110e88b4edc447d92d8e0"
            },
            "downloads": -1,
            "filename": "grokcore.startup-4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "19203c3bf622dfac2f8b6f757bd3afc6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 21447,
            "upload_time": "2024-05-22T15:41:45",
            "upload_time_iso_8601": "2024-05-22T15:41:45.057791Z",
            "url": "https://files.pythonhosted.org/packages/92/b0/8904e6a59df59bd9fa1beb35b1cb74f4cb9425f9ab974e096f45fc0a5b36/grokcore.startup-4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-22 15:41:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zopefoundation",
    "github_project": "grokcore.startup",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "grokcore.startup"
}
        
Elapsed time: 3.91475s