[Checkins] SVN: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/ Further cleanups of stuff we don't need.
Martijn Faassen
faassen at infrae.com
Fri Oct 17 13:18:16 EDT 2008
Log message for revision 92334:
Further cleanups of stuff we don't need.
Changed:
U Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/__init__.py
U Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/components.py
U Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/directive.py
U Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/interfaces.py
U Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/meta.py
D Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/testing.py
-=-
Modified: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/__init__.py
===================================================================
--- Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/__init__.py 2008-10-17 17:17:00 UTC (rev 92333)
+++ Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/__init__.py 2008-10-17 17:18:16 UTC (rev 92334)
@@ -11,77 +11,3 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Grok
-"""
-from zope.interface import implements
-from zope.component import adapts
-
-from martian import ClassGrokker, InstanceGrokker, GlobalGrokker
-from martian import baseclass
-from martian.error import GrokError, GrokImportError
-
-from grokcore.component import Adapter, MultiAdapter, GlobalUtility, Context
-from grokcore.component.decorators import subscribe, adapter, implementer
-from grokcore.component.directive import (
- context, name, title, description, provides, global_utility, direct)
-
-from grokcore.security import Permission
-from grokcore.security import Public
-from grokcore.security import require
-
-from grokcore.view import PageTemplate
-from grokcore.view import PageTemplateFile
-from grokcore.view import DirectoryResource
-from grokcore.view import layer
-from grokcore.view import template
-from grokcore.view import templatedir
-from grokcore.view import skin
-from grokcore.view import url
-from grokcore.view import path
-
-from grokcore.formlib import action
-from grokcore.formlib import AutoFields
-from grokcore.formlib import Fields
-
-from zope.event import notify
-from zope.app.component.hooks import getSite
-from zope.lifecycleevent import (
- IObjectCreatedEvent, ObjectCreatedEvent,
- IObjectModifiedEvent, ObjectModifiedEvent,
- IObjectCopiedEvent, ObjectCopiedEvent)
-
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-
-from zope.app.container.contained import (
- IObjectAddedEvent, ObjectAddedEvent,
- IObjectMovedEvent, ObjectMovedEvent,
- IObjectRemovedEvent, ObjectRemovedEvent,
- IContainerModifiedEvent, ContainerModifiedEvent)
-
-from grok.components import Model, View
-from grok.components import XMLRPC, REST, JSON
-from grok.components import Traverser
-from grok.components import Container, OrderedContainer
-from grok.components import Site, LocalUtility, Annotation
-from grok.components import Application, Form, AddForm, EditForm, DisplayForm
-from grok.components import Indexes
-from grok.components import Role
-from grok.components import RESTProtocol, IRESTLayer
-from grok.interfaces import IRESTSkinType
-from grok.components import ViewletManager, Viewlet
-
-from grok.directive import (local_utility, permissions, site,
- viewletmanager, view, traversable, order)
-
-
-
-# BBB These two functions are meant for test fixtures and should be
-# imported from grok.testing, not from grok.
-from grok.testing import grok, grok_component
-
-# Our __init__ provides the grok API directly so using 'import grok' is enough.
-from grok.interfaces import IGrokAPI
-from zope.interface import moduleProvides
-moduleProvides(IGrokAPI)
-__all__ = list(IGrokAPI)
Modified: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/components.py
===================================================================
--- Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/components.py 2008-10-17 17:17:00 UTC (rev 92333)
+++ Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/components.py 2008-10-17 17:18:16 UTC (rev 92334)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006-2007 Zope Corporation and Contributors.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -11,45 +11,15 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Grok components"""
-import persistent
-import simplejson
-
-import zope.location
from zope import component
from zope import interface
-from zope.securitypolicy.role import Role
-from zope.publisher.browser import BrowserPage
-from zope.publisher.interfaces import NotFound
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.publisher.interfaces.http import IHTTPRequest
-from zope.publisher.publish import mapply
-from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.app.publisher.browser import getDefaultViewName
-from zope.app.container.btree import BTreeContainer
-from zope.app.container.contained import Contained
-from zope.app.container.interfaces import IReadContainer, IObjectAddedEvent
+from zope.app.container.interfaces import IObjectAddedEvent
from zope.app.container.interfaces import IOrderedContainer
-from zope.app.container.contained import notifyContainerModified
-from persistent.list import PersistentList
from zope.app.component.site import SiteManagerContainer
from zope.app.component.site import LocalSiteManager
-from zope.viewlet.manager import ViewletManagerBase
-from zope.viewlet.viewlet import ViewletBase
-
-import grok
-import z3c.flashmessage.interfaces
-import martian.util
-
-import grokcore.view
-import grokcore.formlib
-from grok import interfaces, util
-
-
class Site(SiteManagerContainer):
pass
Modified: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/directive.py
===================================================================
--- Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/directive.py 2008-10-17 17:17:00 UTC (rev 92333)
+++ Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/directive.py 2008-10-17 17:18:16 UTC (rev 92334)
@@ -14,20 +14,13 @@
"""Grok directives.
"""
-import sys
import grok
from zope import interface
from zope.interface.interfaces import IInterface
-from zope.interface.interface import TAGGED_DATA
-from zope.publisher.interfaces.browser import IBrowserView
-
import martian
from martian import util
-from martian.error import GrokImportError, GrokError
-from martian.directive import StoreOnce, StoreMultipleTimes
-from grokcore.component.scan import UnambiguousComponentScope
-from grok import components
+from martian.error import GrokImportError
class local_utility(martian.Directive):
scope = martian.CLASS
Modified: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/interfaces.py
===================================================================
--- Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/interfaces.py 2008-10-17 17:17:00 UTC (rev 92333)
+++ Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/interfaces.py 2008-10-17 17:18:16 UTC (rev 92334)
@@ -11,224 +11,3 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Grok interfaces
-"""
-from zope import interface, schema
-from zope.formlib.interfaces import reConstraint
-from zope.interface.interfaces import IInterface
-from zope.viewlet.interfaces import IViewletManager as IViewletManagerBase
-from zope.app.container.interfaces import IContainer as IContainerBase
-
-import grokcore.component.interfaces
-import grokcore.formlib.interfaces
-import grokcore.security.interfaces
-import grokcore.view.interfaces
-
-# Expose interfaces from grokcore.* packages as well:
-from grokcore.component.interfaces import IContext
-from grokcore.component.interfaces import IGrokErrors
-from grokcore.view.interfaces import ITemplateFileFactory
-from grokcore.view.interfaces import ITemplate
-
-
-class IGrokBaseClasses(grokcore.component.interfaces.IBaseClasses,
- grokcore.security.interfaces.IBaseClasses,
- grokcore.view.interfaces.IBaseClasses):
- Model = interface.Attribute("Base class for persistent content objects "
- "(models).")
- Container = interface.Attribute("Base class for containers.")
- OrderedContainer = interface.Attribute("Base class for ordered containers.")
- Site = interface.Attribute("Mixin class for sites.")
- Application = interface.Attribute("Base class for applications.")
- Annotation = interface.Attribute("Base class for persistent annotations.")
- LocalUtility = interface.Attribute("Base class for local utilities.")
- XMLRPC = interface.Attribute("Base class for XML-RPC methods.")
- JSON = interface.Attribute("Base class for JSON methods.")
- REST = interface.Attribute("Base class for REST views.")
- Traverser = interface.Attribute("Base class for custom traversers.")
- Indexes = interface.Attribute("Base class for catalog index definitions.")
- ViewletManager = interface.Attribute("Base class for viewletmanager.")
- Viewlet = interface.Attribute("Base class for viewlet.")
- Role = interface.Attribute("Base class for roles.")
-
-
-class IGrokDirectives(grokcore.component.interfaces.IDirectives,
- grokcore.security.interfaces.IDirectives,
- grokcore.view.interfaces.IDirectives):
-
- def local_utility(factory, provides=None, name=u'',
- setup=None, public=False, name_in_container=None):
- """Register a local utility.
-
- factory - the factory that creates the local utility
- provides - the interface the utility should be looked up with
- name - the name of the utility
- setup - a callable that receives the utility as its single argument,
- it is called after the utility has been created and stored
- public - if False, the utility will be stored below ++etc++site
- if True, the utility will be stored directly in the site.
- The site should in this case be a container.
- name_in_container - the name to use for storing the utility
- """
-
- def permissions(permissions):
- """Specify the permissions that comprise a role.
- """
-
- def site(class_or_interface):
- """Specifies the site that an indexes definition is for.
-
- It can only be used inside grok.Indexes subclasses.
- """
-
- def order(value=None):
- """Control the ordering of components.
-
- If the value is specified, the order will be determined by sorting on
- it.
- If no value is specified, the order will be determined by definition
- order within the module.
- If the directive is absent, the order will be determined by class name.
- (unfortunately our preferred default behavior on absence which would
- be like grok.order() without argument is hard to implement in Python)
-
- Inter-module order is by dotted name of the module the
- components are in; unless an explicit argument is specified to
- ``grok.order()``, components are grouped by module.
-
- The function grok.util.sort_components can be used to sort
- components according to these rules.
- """
-
-
-class IGrokEvents(interface.Interface):
-
- IObjectCreatedEvent = interface.Attribute("")
-
- ObjectCreatedEvent = interface.Attribute("")
-
- IObjectModifiedEvent = interface.Attribute("")
-
- ObjectModifiedEvent = interface.Attribute("")
-
- IObjectCopiedEvent = interface.Attribute("")
-
- ObjectCopiedEvent = interface.Attribute("")
-
- IObjectAddedEvent = interface.Attribute("")
-
- ObjectAddedEvent = interface.Attribute("")
-
- IObjectMovedEvent = interface.Attribute("")
-
- ObjectMovedEvent = interface.Attribute("")
-
- IObjectRemovedEvent = interface.Attribute("")
-
- ObjectRemovedEvent = interface.Attribute("")
-
- IContainerModifiedEvent = interface.Attribute("")
-
- ContainerModifiedEvent = interface.Attribute("")
-
-
-class IGrokAPI(grokcore.security.interfaces.IGrokcoreSecurityAPI,
- grokcore.view.interfaces.IGrokcoreViewAPI,
- grokcore.formlib.interfaces.IGrokcoreFormlibAPI,
- IGrokBaseClasses, IGrokDirectives,
- IGrokEvents, IGrokErrors):
-
- # BBB this is deprecated
- def grok(dotted_name):
- """Grok a module or package specified by ``dotted_name``.
-
- NOTE: This function will be removed from the public Grok
- public API. For tests and interpreter sessions, use
- grok.testing.grok().
- """
-
- # BBB this is deprecated
- def grok_component(name, component, context=None, module_info=None,
- templates=None):
- """Grok an arbitrary object. Can be useful during testing.
-
- name - the name of the component (class name, or global instance name
- as it would appear in a module).
- component - the object (class, etc) to grok.
- context - the context object (optional).
- module_info - the module being grokked (optional).
- templates - the templates registry (optional).
-
- Note that context, module_info and templates might be required
- for some grokkers which rely on them.
-
- NOTE: This function will be removed from the public Grok
- public API. For tests and interpreter sessions, use
- grok.testing.grok_component().
- """
-
- def notify(event):
- """Send ``event`` to event subscribers."""
-
- def getSite():
- """Get the current site."""
-
-
- IRESTSkinType = interface.Attribute('The REST skin type')
-
-
-class IGrokView(grokcore.view.interfaces.IGrokView):
- """Grok views all provide this interface."""
-
- def application_url(name=None):
- """Return the URL of the closest application object in the
- hierarchy or the URL of a named object (``name`` parameter)
- relative to the closest application object.
- """
-
- def flash(message, type='message'):
- """Send a short message to the user."""
-
-
-class IGrokForm(grokcore.formlib.interfaces.IGrokForm, IGrokView):
- """All Grok forms provides this interface."""
-
-
-class IREST(interface.Interface):
- context = interface.Attribute("Object that the REST handler presents.")
-
- request = interface.Attribute("Request that REST handler was looked"
- "up with.")
-
- body = interface.Attribute(
- """The text of the request body.""")
-
-class IApplication(interface.Interface):
- """Marker-interface for grok application factories.
-
- Used to register applications as utilities to look them up and
- provide a list of grokked applications.
- """
-
-class IIndexDefinition(interface.Interface):
- """Define an index for grok.Indexes.
- """
-
- def setup(catalog, name, context):
- """Set up index called name in given catalog.
-
- Use name for index name and attribute to index. Set up
- index for interface or class context.
- """
-
-class IRESTSkinType(IInterface):
- """Skin type for REST requests.
- """
-
-class IContainer(IContext, IContainerBase):
- """A Grok container.
- """
-
-class IViewletManager(IViewletManagerBase):
- """The Grok viewlet manager.
- """
Modified: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/meta.py
===================================================================
--- Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/meta.py 2008-10-17 17:17:00 UTC (rev 92333)
+++ Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/meta.py 2008-10-17 17:18:16 UTC (rev 92334)
@@ -11,54 +11,25 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Grokkers for the various components."""
-import zope.component.interface
-from zope import interface, component
-from zope.publisher.interfaces.browser import (IDefaultBrowserLayer,
- IBrowserRequest,
- IBrowserPublisher)
-from zope.publisher.interfaces.http import IHTTPRequest
+from zope import component
-from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
-from zope.viewlet.interfaces import IViewletManager, IViewlet
-from zope.securitypolicy.interfaces import IRole
-from zope.securitypolicy.rolepermission import rolePermissionManager
-
-from zope.annotation.interfaces import IAnnotations
-
-from zope.app.publisher.xmlrpc import MethodPublisher
-from zope.app.container.interfaces import IContainer
+from zope.app.container.interfaces import IContainer, IObjectAddedEvent
from zope.app.container.interfaces import INameChooser
-from zope.app.container.contained import contained
-from zope.app.intid import IntIds
-from zope.app.intid.interfaces import IIntIds
-from zope.app.catalog.catalog import Catalog
-from zope.app.catalog.interfaces import ICatalog
-
-from zope.exceptions.interfaces import DuplicationError
-
import martian
from martian.error import GrokError
from martian import util
-import grok
-from grok import components
-from grok.util import make_checker
-from grok.interfaces import IRESTSkinType
-from grok.interfaces import IViewletManager as IGrokViewletManager
+import grokcore.site
-from grokcore.component.scan import determine_module_component
-from grokcore.security.meta import PermissionGrokker
-
from grokcore.view.meta.views import (
default_view_name, default_fallback_to_name)
class SiteGrokker(martian.ClassGrokker):
- martian.component(grok.Site)
+ martian.component(grokcore.site.Site)
martian.priority(500)
- martian.directive(grok.local_utility, name='infos')
+ martian.directive(grokcore.site.local_utility, name='infos')
def execute(self, factory, config, infos, **kw):
if not infos:
@@ -76,7 +47,7 @@
# site class. They will be picked up by a subscriber doing the
# actual registrations in definition order.
factory.__grok_utilities_to_install__ = sorted(infos)
- adapts = (factory, grok.IObjectAddedEvent)
+ adapts = (factory, IObjectAddedEvent)
config.action(
discriminator=None,
Deleted: Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/testing.py
===================================================================
--- Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/testing.py 2008-10-17 17:17:00 UTC (rev 92333)
+++ Sandbox/faassen/grokcore.site/trunk/src/grokcore/site/testing.py 2008-10-17 17:18:16 UTC (rev 92334)
@@ -1,81 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 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.
-#
-##############################################################################
-"""Grok test helpers
-"""
-import sys
-import os.path
-import z3c.testsetup
-from zope.configuration.config import ConfigurationMachine
-from grokcore.component import zcml
-# Provide this import here for BBB reasons:
-from grokcore.component.testing import grok_component
-
-class GrokTestCollector(z3c.testsetup.TestCollector):
-
- def initialize(self):
- # inject the grok ftesting ZCML as fallback...
- if 'zcml_config' in self.settings.keys():
- return
- pkg_path = os.path.dirname(self.package.__file__)
- if os.path.isfile(os.path.join(pkg_path, 'ftesting.zcml')):
- return
- self.settings['zcml_config'] = os.path.join(
- os.path.dirname(__file__), 'ftesting.zcml')
- if 'layer_name' in self.settings.keys():
- return
- self.settings['layer_name'] = 'GrokFunctionalLayer'
-
-def register_all_tests(pkg, *args, **kw):
- return GrokTestCollector(pkg, *args, **kw)
-
-def grok(module_name):
- config = ConfigurationMachine()
- zcml.do_grok('grokcore.component.meta', config)
- zcml.do_grok('grokcore.security.meta', config)
- zcml.do_grok('grokcore.view.meta', config)
- zcml.do_grok('grokcore.view.templatereg', config)
- zcml.do_grok('grokcore.formlib.meta', config)
- zcml.do_grok('grok.meta', config)
- zcml.do_grok(module_name, config)
- config.execute_actions()
-
-def warn(message, category=None, stacklevel=1):
- """Intended to replace warnings.warn in tests.
-
- Modified copy from zope.deprecation.tests to:
-
- * make the signature identical to warnings.warn
- * to check for *.pyc and *.pyo files.
-
- When zope.deprecation is fixed, this warn function can be removed again.
- """
- print "From grok.testing's warn():"
-
- frame = sys._getframe(stacklevel)
- path = frame.f_globals['__file__']
- if path.endswith('.pyc') or path.endswith('.pyo'):
- path = path[:-1]
-
- file = open(path)
- lineno = frame.f_lineno
- for i in range(lineno):
- line = file.readline()
-
- print "%s:%s: %s: %s\n %s" % (
- path,
- frame.f_lineno,
- category.__name__,
- message,
- line.strip(),
- )
More information about the Checkins
mailing list