grokcore.site


Namegrokcore.site JSON
Version 4.0 PyPI version JSON
download
home_pagehttps://github.com/zopefoundation/grokcore.site
SummaryGrok-like configuration for Zope local site and utilities
upload_time2023-07-11 06:34:50
maintainer
docs_urlNone
authorGrok Team
requires_python>=3.7
licenseZPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
This package provides support to write local site and utilities for
Zope directly in Python (without ZCML).

.. contents::


Setting up ``grokcore.site``
============================

This package is essentially set up like the `grokcore.component`_
package, please refer to its documentation for details.  The only
additional ZCML line you will need is::

  <include package="grokcore.site" />

Put this somewhere near the top of your root ZCML file but below the
line where you include ``grokcore.component``'s configuration.


Examples
========

Global utilities are already managed by `grokcore.component`_.

Here a simple example of a local utility::

  from zope.interface import implements, Interface
  import grokcore.site

  class IKangaroo(Interface):

      def jump():
         """Make all kangaroos jump somewhere.
         """

  class KangarooUtility(grokcore.site.LocalUtility):
      implements(IKangaroo)

      def jump(self):
          pass


Now, we can register our utility to a local site. That will create
automatically, and register that utility when we create that site::


   class Jungle(grokcore.site.Site):

       grokcore.site.local_utility(KangarooUtility, IKangaroo)


If you don't add the last line, you will still have your site, but
nothing to make jump your kangaroo. Then, you will be able to add
manually by hand after (if you want).


API Overview
============

Base classes
------------

``Site``
   Base class for your site.

``LocalUtility``
   Base class for a ZODB-persitent local utility.


Directives
----------

``local_utility(factory, provides=None, name=u'', setup=None, public=False, name_in_container=None``)
   Directive used on a site to register a local utility at the
   creation time:

   ``factory``
      Would be the component to register (required parameter),

   ``provides``
      Would be the interface used to query the local utility (required
      parameter),

   ``name``
      Would be the name used to query the local utility,

   ``setup``
      Would be a function taking parameter. If defined it will be
      called after the utility is created with it as first and unique
      parameter.

   ``public``
      If true, the utility will be created in the site container
      itself, not in the site manager, and public will be able to
      access it directly.

   ``name_in_container``
      Would be used as id for the utility in container itwill be
      created. If not defined it will ask NameChooser to pick a name
      for it.

In addition, the ``grokcore.site`` package exposes the
`grokcore.component`_ API.

.. _grokcore.component: http://pypi.python.org/pypi/grokcore.component

Changes
=======

4.0 (2023-07-11)
----------------

- Drop support for Python 2.7, 3.5, 3.6.

- Add support for Python 3.9, 3.10, 3.11.

- Adapt code to ``zope.site >= 4.4`` thus requiring at least that version.
  (`#7 <https://github.com/zopefoundation/grokcore.site/pull/7>`_)

3.1 (2020-09-02)
----------------

- Fix DeprecationWarnings.

- Drop support for Python 3.4 and add support for 3.7 and 3.8.

3.0.3 (2018-01-12)
------------------

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

3.0.2 (2018-01-11)
------------------

- Do not import `getSite` from `zope.site.hooks` anymore but from
  `zope.component.hooks`.

3.0.1 (2018-01-10)
------------------

- Fix dependencies by removing ZODB3.

3.0.0 (2018-01-05)
------------------

- Python 3 compatibility.

1.8 (2016-09-21)
----------------

- When removing a site make sure reference are removed from the parent
  site.

1.7.1 (2016-01-29)
------------------

- Update tests.

1.7 (2015-06-11)
----------------

- Add a new directive ``install_on`` that is usable on a site. This
  directive let you customize when (namely the event) to install the
  configured local sites.

- Rename ``ApplicationInitializedEvent`` to ``ApplicationAddedEvent``.

- When the ``IApplicationAddedEvent`` is triggered the new application
  will be current Zope local site. The site is restored after the
  event.

1.6.1 (2012-05-02)
------------------

- Exposed ApplicationInitializedEvent and IApplicationInitializedEvent.

- Added the missing import for the exposed IApplication interface.

1.6 (2012-05-01)
----------------

- Moved the directive `site` from Grok to this package.

- Moved the component `Application` and all the related utilities from Grok
  to this package.

1.5 (2011-01-03)
----------------

- Moved IApplication and getApplication from the Grok package into
  this one.

1.4 (2010-11-01)
----------------

- Upped versions requirements for martian and grokcore.component.

1.3 (2010-10-18)
----------------

- Made package comply to repository policy.

- Update functional tests to only use zope.app.appsetup instead
  of zope.app.testing.

- Update functional tests not to require zope.app.zcmlfiles
  anymore.

1.2 (2009-12-20)
----------------

* Migrated imports from zope.app.component to zope.site.

1.1 (2009-09-18)
----------------

* Updated dependencies (added missing ones and added separate test
  dependencies).

* A local utility now implements IAttributeAnnotatable.

* Update code documentation from Grok itself.

* Use 1.0b2 versions.cfg in Grok's release info instead of a local
  copy; a local copy for all grokcore packages is just too hard to
  maintain.


1.0.1 (2009-06-30)
------------------

* Reupload to pypi with a correct version of Python which doesn't have
  a distutils bug.

1.0 (2009-06-29)
----------------

* Created ``grokcore.site`` by factoring local site based components,
  grokkers and directives out of Grok.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zopefoundation/grokcore.site",
    "name": "grokcore.site",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Grok Team",
    "author_email": "zope-dev@zope.dev",
    "download_url": "https://files.pythonhosted.org/packages/76/12/e0409acc3347fd9278fec8ac391dee862743a01427dbcf352a59f168925f/grokcore.site-4.0.tar.gz",
    "platform": null,
    "description": "\nThis package provides support to write local site and utilities for\nZope directly in Python (without ZCML).\n\n.. contents::\n\n\nSetting up ``grokcore.site``\n============================\n\nThis package is essentially set up like the `grokcore.component`_\npackage, please refer to its documentation for details.  The only\nadditional ZCML line you will need is::\n\n  <include package=\"grokcore.site\" />\n\nPut this somewhere near the top of your root ZCML file but below the\nline where you include ``grokcore.component``'s configuration.\n\n\nExamples\n========\n\nGlobal utilities are already managed by `grokcore.component`_.\n\nHere a simple example of a local utility::\n\n  from zope.interface import implements, Interface\n  import grokcore.site\n\n  class IKangaroo(Interface):\n\n      def jump():\n         \"\"\"Make all kangaroos jump somewhere.\n         \"\"\"\n\n  class KangarooUtility(grokcore.site.LocalUtility):\n      implements(IKangaroo)\n\n      def jump(self):\n          pass\n\n\nNow, we can register our utility to a local site. That will create\nautomatically, and register that utility when we create that site::\n\n\n   class Jungle(grokcore.site.Site):\n\n       grokcore.site.local_utility(KangarooUtility, IKangaroo)\n\n\nIf you don't add the last line, you will still have your site, but\nnothing to make jump your kangaroo. Then, you will be able to add\nmanually by hand after (if you want).\n\n\nAPI Overview\n============\n\nBase classes\n------------\n\n``Site``\n   Base class for your site.\n\n``LocalUtility``\n   Base class for a ZODB-persitent local utility.\n\n\nDirectives\n----------\n\n``local_utility(factory, provides=None, name=u'', setup=None, public=False, name_in_container=None``)\n   Directive used on a site to register a local utility at the\n   creation time:\n\n   ``factory``\n      Would be the component to register (required parameter),\n\n   ``provides``\n      Would be the interface used to query the local utility (required\n      parameter),\n\n   ``name``\n      Would be the name used to query the local utility,\n\n   ``setup``\n      Would be a function taking parameter. If defined it will be\n      called after the utility is created with it as first and unique\n      parameter.\n\n   ``public``\n      If true, the utility will be created in the site container\n      itself, not in the site manager, and public will be able to\n      access it directly.\n\n   ``name_in_container``\n      Would be used as id for the utility in container itwill be\n      created. If not defined it will ask NameChooser to pick a name\n      for it.\n\nIn addition, the ``grokcore.site`` package exposes the\n`grokcore.component`_ API.\n\n.. _grokcore.component: http://pypi.python.org/pypi/grokcore.component\n\nChanges\n=======\n\n4.0 (2023-07-11)\n----------------\n\n- Drop support for Python 2.7, 3.5, 3.6.\n\n- Add support for Python 3.9, 3.10, 3.11.\n\n- Adapt code to ``zope.site >= 4.4`` thus requiring at least that version.\n  (`#7 <https://github.com/zopefoundation/grokcore.site/pull/7>`_)\n\n3.1 (2020-09-02)\n----------------\n\n- Fix DeprecationWarnings.\n\n- Drop support for Python 3.4 and add support for 3.7 and 3.8.\n\n3.0.3 (2018-01-12)\n------------------\n\n- Rearrange tests such that Travis CI can pick up all functional tests too.\n\n3.0.2 (2018-01-11)\n------------------\n\n- Do not import `getSite` from `zope.site.hooks` anymore but from\n  `zope.component.hooks`.\n\n3.0.1 (2018-01-10)\n------------------\n\n- Fix dependencies by removing ZODB3.\n\n3.0.0 (2018-01-05)\n------------------\n\n- Python 3 compatibility.\n\n1.8 (2016-09-21)\n----------------\n\n- When removing a site make sure reference are removed from the parent\n  site.\n\n1.7.1 (2016-01-29)\n------------------\n\n- Update tests.\n\n1.7 (2015-06-11)\n----------------\n\n- Add a new directive ``install_on`` that is usable on a site. This\n  directive let you customize when (namely the event) to install the\n  configured local sites.\n\n- Rename ``ApplicationInitializedEvent`` to ``ApplicationAddedEvent``.\n\n- When the ``IApplicationAddedEvent`` is triggered the new application\n  will be current Zope local site. The site is restored after the\n  event.\n\n1.6.1 (2012-05-02)\n------------------\n\n- Exposed ApplicationInitializedEvent and IApplicationInitializedEvent.\n\n- Added the missing import for the exposed IApplication interface.\n\n1.6 (2012-05-01)\n----------------\n\n- Moved the directive `site` from Grok to this package.\n\n- Moved the component `Application` and all the related utilities from Grok\n  to this package.\n\n1.5 (2011-01-03)\n----------------\n\n- Moved IApplication and getApplication from the Grok package into\n  this one.\n\n1.4 (2010-11-01)\n----------------\n\n- Upped versions requirements for martian and grokcore.component.\n\n1.3 (2010-10-18)\n----------------\n\n- Made package comply to repository policy.\n\n- Update functional tests to only use zope.app.appsetup instead\n  of zope.app.testing.\n\n- Update functional tests not to require zope.app.zcmlfiles\n  anymore.\n\n1.2 (2009-12-20)\n----------------\n\n* Migrated imports from zope.app.component to zope.site.\n\n1.1 (2009-09-18)\n----------------\n\n* Updated dependencies (added missing ones and added separate test\n  dependencies).\n\n* A local utility now implements IAttributeAnnotatable.\n\n* Update code documentation from Grok itself.\n\n* Use 1.0b2 versions.cfg in Grok's release info instead of a local\n  copy; a local copy for all grokcore packages is just too hard to\n  maintain.\n\n\n1.0.1 (2009-06-30)\n------------------\n\n* Reupload to pypi with a correct version of Python which doesn't have\n  a distutils bug.\n\n1.0 (2009-06-29)\n----------------\n\n* Created ``grokcore.site`` by factoring local site based components,\n  grokkers and directives out of Grok.\n",
    "bugtrack_url": null,
    "license": "ZPL",
    "summary": "Grok-like configuration for Zope local site and utilities",
    "version": "4.0",
    "project_urls": {
        "Homepage": "https://github.com/zopefoundation/grokcore.site"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11b51b95a429bbb9dc7a135d932a3a3f9ee3374d5c9339859ac912f81922009e",
                "md5": "88d19c4f509e5938f2cebdf13fbbbe1a",
                "sha256": "efd89ce2b551610ce3bb9448d55cfc9e74d7c8f184c15afee8bee6b6a66c06e7"
            },
            "downloads": -1,
            "filename": "grokcore.site-4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "88d19c4f509e5938f2cebdf13fbbbe1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 26657,
            "upload_time": "2023-07-11T06:34:48",
            "upload_time_iso_8601": "2023-07-11T06:34:48.673339Z",
            "url": "https://files.pythonhosted.org/packages/11/b5/1b95a429bbb9dc7a135d932a3a3f9ee3374d5c9339859ac912f81922009e/grokcore.site-4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7612e0409acc3347fd9278fec8ac391dee862743a01427dbcf352a59f168925f",
                "md5": "781d4679955d57c142478a859d4b6b05",
                "sha256": "872586c6e5a84609f59e2294f32b105da72da0333dc9f0a41b150716e3dafe38"
            },
            "downloads": -1,
            "filename": "grokcore.site-4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "781d4679955d57c142478a859d4b6b05",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 20370,
            "upload_time": "2023-07-11T06:34:50",
            "upload_time_iso_8601": "2023-07-11T06:34:50.567284Z",
            "url": "https://files.pythonhosted.org/packages/76/12/e0409acc3347fd9278fec8ac391dee862743a01427dbcf352a59f168925f/grokcore.site-4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 06:34:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zopefoundation",
    "github_project": "grokcore.site",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "grokcore.site"
}
        
Elapsed time: 0.08717s