[Checkins] SVN: grokcore.site/trunk/s Check if the code is up to date with the Grok trunk. Port over comments which have been added.
Sylvain Viollon
sylvain at infrae.com
Fri Jun 5 10:20:02 EDT 2009
Log message for revision 100651:
Check if the code is up to date with the Grok trunk. Port over comments which have been added.
Clean unused imports.
Changed:
U grokcore.site/trunk/setup.py
U grokcore.site/trunk/src/grokcore/site/__init__.py
U grokcore.site/trunk/src/grokcore/site/components.py
U grokcore.site/trunk/src/grokcore/site/directive.py
U grokcore.site/trunk/src/grokcore/site/interfaces.py
U grokcore.site/trunk/src/grokcore/site/meta.py
U grokcore.site/trunk/src/grokcore/site/subscriber.py
-=-
Modified: grokcore.site/trunk/setup.py
===================================================================
--- grokcore.site/trunk/setup.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/setup.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -34,6 +34,7 @@
zip_safe=False,
install_requires=['setuptools',
'martian',
+ 'ZODB3',
'zope.component',
'zope.interface',
'zope.app.component',
Modified: grokcore.site/trunk/src/grokcore/site/__init__.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/__init__.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/src/grokcore/site/__init__.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+# Copyright (c) 2006-2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
Modified: grokcore.site/trunk/src/grokcore/site/components.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/components.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/src/grokcore/site/components.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+# Copyright (c) 2006-2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -12,19 +12,43 @@
#
##############################################################################
-import grokcore.component
from grokcore.component.interfaces import IContext
from persistent import Persistent
from zope.interface import implements
-from zope.app.component.site import SiteManagerContainer, LocalSiteManager
+from zope.app.component.site import SiteManagerContainer
from zope.app.container.contained import Contained
+
class Site(SiteManagerContainer):
- pass
+ """Mixin for creating sites in Grok applications.
+ When an application `grok.Model` or `grok.Container` also inherits
+ from `grok.Site`, then it can additionally support the registration
+ of local Component Architecture entities like `grok.LocalUtility`
+ and `grok.Indexes` objects; see those classes for more information.
+
+ """
+
+
class LocalUtility(Contained, Persistent):
+ """The base class for local utilities in Grok applications.
+
+ Although application developers can create local utilies without
+ actually subclassing `grok.LocalUtility`, they gain three benefits
+ from doing so. First, their code is more readable because their
+ classes "look like" local utilities to casual readers. Second,
+ their utility will know how to persist itself to the Zope database,
+ which means that they can set its object attributes and know that
+ the values are getting automatically saved. Third, they can omit
+ the `grok.provides()` directive naming the interface that the
+ utility provides, if their class only `grok.implements()` a single
+ interface (unless the interface is one that the `grok.LocalUtility`
+ already implements, in which case Grok cannot tell them apart, and
+ `grok.provides()` must be used explicitly anyway).
+
+ """
implements(IContext)
Modified: grokcore.site/trunk/src/grokcore/site/directive.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/directive.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/src/grokcore/site/directive.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -72,7 +72,17 @@
class LocalUtilityInfo(object):
+ """The information about how to register a local utility.
+ An instance of this class is created for each `grok.local_utility()`
+ in a Grok application's code, to remember how the user wants their
+ local utility registered. Later, whenever the application creates
+ new instances of the site or application for which the local utility
+ directive was supplied, this block of information is used as the
+ parameters to the creation of the local utility which is created
+ along with the new site in the Zope database.
+
+ """
_order = 0
def __init__(self, factory, provides, name=u'',
Modified: grokcore.site/trunk/src/grokcore/site/interfaces.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/interfaces.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/src/grokcore/site/interfaces.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# Copyright (c) 2006-2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -14,10 +14,12 @@
from zope.interface import Interface, Attribute
+
class IBaseClasses(Interface):
Site = Attribute("Mixin class for sites.")
LocalUtility = Attribute("Base class for local utilities.")
+
class IDirectives(Interface):
def local_utility(factory, provides=None, name=u'',
setup=None, public=False, name_in_container=None):
@@ -33,11 +35,12 @@
The site should in this case be a container.
name_in_container - the name to use for storing the utility
"""
-
+
def provides(interface):
"""Explicitly specify with which interface a component will be
looked up."""
-
+
+
class IGrokcoreSiteAPI(IBaseClasses, IDirectives):
"""grokcore.site's public API."""
Modified: grokcore.site/trunk/src/grokcore/site/meta.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/meta.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/src/grokcore/site/meta.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -1,6 +1,6 @@
#############################################################################
#
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# Copyright (c) 2006-2009 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -19,10 +19,10 @@
import martian
from martian.error import GrokError
-from martian import util
import grokcore.site
+
class SiteGrokker(martian.ClassGrokker):
martian.component(grokcore.site.Site)
martian.priority(500)
Modified: grokcore.site/trunk/src/grokcore/site/subscriber.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/subscriber.py 2009-06-05 14:04:46 UTC (rev 100650)
+++ grokcore.site/trunk/src/grokcore/site/subscriber.py 2009-06-05 14:20:02 UTC (rev 100651)
@@ -1,3 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2006-2009 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.
+#
+##############################################################################
+
import grokcore.component
from zope.app.component.site import LocalSiteManager
from zope.app.container.interfaces import IObjectAddedEvent
@@ -6,6 +20,14 @@
@grokcore.component.subscribe(Site, IObjectAddedEvent)
def addSiteHandler(site, event):
+ """Add a local site manager to a Grok site object upon its creation.
+
+ Grok registers this function so that it gets called each time a
+ `grok.Site` instance is added to a container. It creates a local
+ site manager and installs it on the newly created site.
+
+ """
+
sitemanager = LocalSiteManager(site)
# LocalSiteManager creates the 'default' folder in its __init__.
# It's not needed anymore in new versions of Zope 3, therefore we
More information about the Checkins
mailing list