[Checkins] SVN: grok/trunk/src/grok/ cosmetics (PEP8-friendlier,
trailing whitespace, copyright year)
Philipp von Weitershausen
philikon at philikon.de
Mon Jan 8 08:45:36 EST 2007
Log message for revision 71805:
cosmetics (PEP8-friendlier, trailing whitespace, copyright year)
Changed:
U grok/trunk/src/grok/__init__.py
U grok/trunk/src/grok/_grok.py
U grok/trunk/src/grok/components.py
U grok/trunk/src/grok/directive.py
U grok/trunk/src/grok/formlib.py
U grok/trunk/src/grok/ftests/static/simple.py
U grok/trunk/src/grok/ftests/test_grok_functional.py
U grok/trunk/src/grok/ftests/xmlrpc_helper.py
U grok/trunk/src/grok/meta.py
U grok/trunk/src/grok/util.py
-=-
Modified: grok/trunk/src/grok/__init__.py
===================================================================
--- grok/trunk/src/grok/__init__.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/__init__.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006 Zope Corporation and Contributors.
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
Modified: grok/trunk/src/grok/_grok.py
===================================================================
--- grok/trunk/src/grok/_grok.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/_grok.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -49,7 +49,7 @@
# now grok the grokkers
grokker.grokkerRegistry.grok(scan.module_info_from_module(meta))
-
+
def addSiteHandler(site, event):
sitemanager = LocalSiteManager(site)
# LocalSiteManager creates the 'default' folder in its __init__.
@@ -84,9 +84,10 @@
for sub_module_info in module_info.getSubModuleInfos():
grok_tree(sub_module_info)
-
+
# decorators
class SubscribeDecorator:
+
def __init__(self, *args):
self.subscribed = args
Modified: grok/trunk/src/grok/components.py
===================================================================
--- grok/trunk/src/grok/components.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/components.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -78,7 +78,7 @@
def match(self, obj):
return isinstance(obj, self.component_class)
-
+
def register(self, context, name, instance, module_info, templates):
raise NotImplementedError
@@ -188,6 +188,7 @@
class GrokViewAbsoluteURL(AbsoluteURL):
+
def _getContextName(self, context):
return getattr(context, '__view_name__', None)
# XXX breadcrumbs method on AbsoluteURL breaks as it does not use
Modified: grok/trunk/src/grok/directive.py
===================================================================
--- grok/trunk/src/grok/directive.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/directive.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006 Zope Corporation and Contributors.
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -30,6 +30,7 @@
def frame_is_class(frame):
return '__module__' in frame.f_locals
+
class IDirectiveContext(interface.Interface):
description = interface.Attribute("The correct place in which the "
"directive can be used.")
@@ -56,6 +57,7 @@
def matches(self, frame):
return frame_is_module(frame)
+
class ClassOrModuleDirectiveContext(object):
interface.implements(IDirectiveContext)
@@ -64,6 +66,7 @@
def matches(self, frame):
return frame_is_module(frame) or frame_is_class(frame)
+
class Directive(object):
"""
Directive sets a value into the context's locals as __<name>__
@@ -88,10 +91,11 @@
def check_arguments(self, *args, **kw):
raise NotImplementedError
- # to get a correct error message, we construct a function that has the same
- # signature as check_arguments(), but without "self".
+ # to get a correct error message, we construct a function that has
+ # the same signature as check_arguments(), but without "self".
def check_argument_signature(self, *arguments, **kw):
- args, varargs, varkw, defaults = inspect.getargspec(self.check_arguments)
+ args, varargs, varkw, defaults = inspect.getargspec(
+ self.check_arguments)
argspec = inspect.formatargspec(args[1:], varargs, varkw, defaults)
exec("def signature_checker" + argspec + ": pass")
try:
@@ -113,6 +117,7 @@
def store(self, frame, value):
raise NotImplementedError
+
class OnceDirective(Directive):
def store(self, frame, value):
if self.local_name in frame.f_locals:
@@ -121,20 +126,24 @@
self.directive_context.description))
frame.f_locals[self.local_name] = value
+
class MultipleTimesDirective(Directive):
def store(self, frame, value):
values = frame.f_locals.get(self.local_name, [])
values.append(value)
frame.f_locals[self.local_name] = values
+
class SingleValue(object):
- # Even though the value_factory is called with (*args, **kw), we're safe
- # since check_arguments would have bailed out with a TypeError if the number
- # arguments we were called with was not what we expect here.
+ # Even though the value_factory is called with (*args, **kw),
+ # we're safe since check_arguments would have bailed out with a
+ # TypeError if the number arguments we were called with was not
+ # what we expect here.
def value_factory(self, value):
return value
+
class BaseTextDirective(object):
"""
Base directive that only accepts unicode/ASCII values.
@@ -145,17 +154,20 @@
raise GrokImportError("You can only pass unicode or ASCII to "
"%s." % self.name)
+
class SingleTextDirective(BaseTextDirective, SingleValue, OnceDirective):
"""
Directive that accepts a single unicode/ASCII value, only once.
"""
+
class MultipleTextDirective(BaseTextDirective, SingleValue,
MultipleTimesDirective):
"""
Directive that accepts a single unicode/ASCII value, multiple times.
"""
+
class InterfaceOrClassDirective(SingleValue, OnceDirective):
"""
Directive that only accepts classes or interface values.
@@ -166,6 +178,7 @@
raise GrokImportError("You can only pass classes or interfaces to "
"%s." % self.name)
+
class InterfaceDirective(SingleValue, OnceDirective):
"""
Directive that only accepts interface values.
@@ -176,6 +189,7 @@
raise GrokImportError("You can only pass interfaces to "
"%s." % self.name)
+
class GlobalUtilityDirective(MultipleTimesDirective):
def check_arguments(self, factory, provides=None, name=u''):
if provides is not None and not IInterface.providedBy(provides):
@@ -185,6 +199,7 @@
def value_factory(self, *args, **kw):
return GlobalUtilityInfo(*args, **kw)
+
class GlobalUtilityInfo(object):
def __init__(self, factory, provides=None, name=u''):
self.factory = factory
@@ -197,6 +212,7 @@
name = util.class_annotation(factory, 'grok.name', u'')
self.name = name
+
class LocalUtilityDirective(MultipleTimesDirective):
def check_arguments(self, factory, provides=None, name=u'',
setup=None, public=False, name_in_container=None):
@@ -207,6 +223,7 @@
def value_factory(self, *args, **kw):
return LocalUtilityInfo(*args, **kw)
+
class LocalUtilityInfo(object):
def __init__(self, factory, provides=None, name=u'',
setup=None, public=False, name_in_container=None):
@@ -219,6 +236,7 @@
self.public = public
self.name_in_container = name_in_container
+
class RequireDirective(BaseTextDirective, SingleValue, MultipleTimesDirective):
def store(self, frame, value):
Modified: grok/trunk/src/grok/formlib.py
===================================================================
--- grok/trunk/src/grok/formlib.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/formlib.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -1,4 +1,5 @@
-import os, types
+import os
+import types
from zope import interface
from zope.interface.interfaces import IInterface
from zope.formlib import form
Modified: grok/trunk/src/grok/ftests/static/simple.py
===================================================================
--- grok/trunk/src/grok/ftests/static/simple.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/ftests/static/simple.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -7,11 +7,13 @@
>>> from zope.testbrowser.testing import Browser
>>> browser = Browser()
>>> browser.handleErrors = False
- >>> browser.open('http://localhost/@@/grok.ftests.static.simple_fixture/file.txt')
+ >>> browser.open('http://localhost/@@/grok.ftests.static.simple_fixture/'
+ ... 'file.txt')
>>> print browser.contents
some text
-We use a special name 'static' in page templates to allow easy linking to resources:
+We use a special name 'static' in page templates to allow easy linking
+to resources:
>>> root = getRootFolder()
>>> from grok.ftests.static.simple_fixture.ellie import Mammoth
Modified: grok/trunk/src/grok/ftests/test_grok_functional.py
===================================================================
--- grok/trunk/src/grok/ftests/test_grok_functional.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/ftests/test_grok_functional.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -1,7 +1,8 @@
import unittest
from pkg_resources import resource_listdir
from zope.testing import doctest
-from zope.app.testing.functional import HTTPCaller, getRootFolder, FunctionalTestSetup, sync, Functional
+from zope.app.testing.functional import (HTTPCaller, getRootFolder,
+ FunctionalTestSetup, sync, Functional)
# XXX bastardized from zope.app.testing.functional.FunctionalDocFileSuite :-(
def FunctionalDocTestSuite(*paths, **kw):
Modified: grok/trunk/src/grok/ftests/xmlrpc_helper.py
===================================================================
--- grok/trunk/src/grok/ftests/xmlrpc_helper.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/ftests/xmlrpc_helper.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -43,14 +43,16 @@
host, extra_headers, x509 = self.get_host_info(host)
if extra_headers:
- request += "Authorization: %s\n" % (dict(extra_headers)["Authorization"],)
+ request += "Authorization: %s\n" \
+ % (dict(extra_headers)["Authorization"],)
request += "\n" + request_body
response = HTTPCaller()(request, handle_errors=self.handleErrors)
errcode = response.getStatus()
errmsg = response.getStatusString()
- # This is not the same way that the normal transport deals with the headers.
+ # This is not the same way that the normal transport deals
+ # with the headers.
headers = response.getHeaders()
if errcode != 200:
Modified: grok/trunk/src/grok/meta.py
===================================================================
--- grok/trunk/src/grok/meta.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/meta.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -19,7 +19,6 @@
from grok.error import GrokError
-
class ModelGrokker(grok.ClassGrokker):
component_class = grok.Model
Modified: grok/trunk/src/grok/util.py
===================================================================
--- grok/trunk/src/grok/util.py 2007-01-08 13:29:41 UTC (rev 71804)
+++ grok/trunk/src/grok/util.py 2007-01-08 13:45:34 UTC (rev 71805)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2006 Zope Corporation and Contributors.
+# Copyright (c) 2006-2007 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
More information about the Checkins
mailing list