[Checkins] SVN: five.pt/trunk/src/five/pt/ pep8 fixes
Ross Patterson
me at rpatterson.net
Sat Oct 23 16:31:56 EDT 2010
Log message for revision 117826:
pep8 fixes
Changed:
U five.pt/trunk/src/five/pt/__init__.py
U five.pt/trunk/src/five/pt/expressions.py
U five.pt/trunk/src/five/pt/pagetemplate.py
U five.pt/trunk/src/five/pt/patches.py
U five.pt/trunk/src/five/pt/tests/test_doctests.py
U five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py
U five.pt/trunk/src/five/pt/zcml.py
-=-
Modified: five.pt/trunk/src/five/pt/__init__.py
===================================================================
--- five.pt/trunk/src/five/pt/__init__.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/__init__.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -1,5 +1,6 @@
import patches
+
def initialize(site):
import chameleon.core.config
Modified: five.pt/trunk/src/five/pt/expressions.py
===================================================================
--- five.pt/trunk/src/five/pt/expressions.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/expressions.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -80,7 +80,7 @@
if call is False:
return base
-
+
if getattr(base, '__call__', _marker) is not _marker or callable(base):
# here's where we're different from the standard path
# traverser
@@ -88,16 +88,20 @@
return base
+
class PathTranslator(PathTranslator):
path_traverse = FiveTraverser()
+
class FiveExistsTraverser(ZopeExistsTraverser):
exceptions = AttributeError, LookupError, TypeError, \
NotFound, Unauthorized, TraversalError
+
class ExistsTranslator(ExistsTranslator):
path_traverse = FiveExistsTraverser()
+
class FiveContentProviderTraverser(object):
def __call__(self, context, request, view, name):
cp = component.queryMultiAdapter(
@@ -113,6 +117,7 @@
cp.update()
return cp.render()
+
class FiveProviderTranslator(ProviderTranslator):
content_provider_traverser = FiveContentProviderTraverser()
Modified: five.pt/trunk/src/five/pt/pagetemplate.py
===================================================================
--- five.pt/trunk/src/five/pt/pagetemplate.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/pagetemplate.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -11,11 +11,13 @@
from z3c.pt import pagetemplate
+
def get_physical_root(context):
method = aq_get(context, 'getPhysicalRoot', None)
if method is not None:
return method()
+
def same_type(arg1, *args):
"""Compares the class or type of two or more objects. Copied from
RestrictedPython.
@@ -32,6 +34,7 @@
return a
return b
+
class BaseTemplate(pagetemplate.BaseTemplate):
"""Zope 2-compatible page template class."""
@@ -74,9 +77,11 @@
return namespace
+
class BaseTemplateFile(BaseTemplate, pagetemplate.BaseTemplateFile):
"""Zope 2-compatible page template file class."""
+
class ViewPageTemplate(pagetemplate.ViewPageTemplate):
encoding = 'UTF-8'
@@ -115,7 +120,9 @@
return namespace
-class ViewPageTemplateFile(ViewPageTemplate, pagetemplate.ViewPageTemplateFile):
+
+class ViewPageTemplateFile(ViewPageTemplate,
+ pagetemplate.ViewPageTemplateFile):
"""If ``filename`` is a relative path, the module path of the
class where the instance is used to get an absolute path."""
Modified: five.pt/trunk/src/five/pt/patches.py
===================================================================
--- five.pt/trunk/src/five/pt/patches.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/patches.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -8,8 +8,8 @@
Chameleon template instance, transparent to the calling class.
"""
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile as \
- ZopeViewPageTemplateFile
+from zope.app.pagetemplate.viewpagetemplatefile import (
+ ViewPageTemplateFile as ZopeViewPageTemplateFile)
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.PageTemplates.PageTemplateFile import PageTemplate
Modified: five.pt/trunk/src/five/pt/tests/test_doctests.py
===================================================================
--- five.pt/trunk/src/five/pt/tests/test_doctests.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/tests/test_doctests.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -14,18 +14,22 @@
import z3c.pt
import five.pt
+
class TestParticipation(object):
principal = 'foobar'
interaction = None
+
def setUp(test):
zope.component.testing.setUp(test)
zope.configuration.xmlconfig.XMLConfig('meta.zcml', five.pt)()
zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
-
+
+
def tearDown(test):
zope.component.testing.tearDown(test)
+
def test_suite():
import five.pt.tests
path = five.pt.tests.__path__[0]
@@ -35,7 +39,7 @@
path=path,
interface=zope.interface,
component=zope.component)
-
+
return unittest.TestSuite([
doctest.DocFileSuite(
"zcml.txt",
Modified: five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py
===================================================================
--- five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/tests/test_viewpagetemplatefile.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -5,9 +5,11 @@
from five.pt.pagetemplate import ViewPageTemplateFile
+
class SimpleView(BrowserView):
index = ViewPageTemplateFile('simple.pt')
+
class LocalsView(BrowserView):
def available(self):
return 'yes'
@@ -17,12 +19,15 @@
index = ViewPageTemplateFile('locals.pt')
+
class OptionsView(BrowserView):
index = ViewPageTemplateFile('options.pt')
+
class MissingView(BrowserView):
index = ViewPageTemplateFile('missing.pt')
+
class TestPageTemplateFile(ZopeTestCase):
def afterSetUp(self):
from Products.Five import zcml
Modified: five.pt/trunk/src/five/pt/zcml.py
===================================================================
--- five.pt/trunk/src/five/pt/zcml.py 2010-10-23 20:14:44 UTC (rev 117825)
+++ five.pt/trunk/src/five/pt/zcml.py 2010-10-23 20:31:56 UTC (rev 117826)
@@ -13,6 +13,7 @@
from five.pt.pagetemplate import ViewPageTemplateFile
+
def SimpleViewClass(src, offering=None, used_for=None, bases=(), name=u''):
if offering is None:
offering = sys._getframe(1).f_globals
@@ -28,15 +29,17 @@
return class_
-def SimpleViewletClass(src, offering=None, bases=(), attributes=None, name=u''):
+
+def SimpleViewletClass(src, offering=None, bases=(), attributes=None,
+ name=u''):
if offering is None:
offering = sys._getframe(1).f_globals
# Create the base class hierarchy
bases += (viewlet.simple, viewlet.ViewletBase)
- attrs = {'index' : ViewPageTemplateFile(src, offering),
- '__name__' : name}
+ attrs = {'index': ViewPageTemplateFile(src, offering),
+ '__name__': name}
if attributes:
attrs.update(attributes)
@@ -45,28 +48,33 @@
return class_
+
def page_directive(_context, name, *args, **kwargs):
class_ = kwargs.get('class_')
template = kwargs.get('template')
if template:
bases = class_ and (class_,) or ()
- kwargs['class_'] = SimpleViewClass(str(template), bases=bases, name=name)
+ kwargs['class_'] = SimpleViewClass(
+ str(template), bases=bases, name=name)
del kwargs['template']
return viewmeta.page(_context, name, *args, **kwargs)
+
def viewlet_directive(_context, name, *args, **kwargs):
class_ = kwargs.get('class_')
template = kwargs.get('template')
if template:
bases = class_ and (class_,) or ()
- kwargs['class_'] = SimpleViewletClass(str(template), bases=bases, name=name)
+ kwargs['class_'] = SimpleViewletClass(
+ str(template), bases=bases, name=name)
del kwargs['template']
return viewletmeta.viewletDirective(_context, name, *args, **kwargs)
+
def viewlet_manager_directive(_context, name, *args, **kwargs):
template = kwargs.pop('template', None)
provides = kwargs.setdefault('provides', IViewletManager)
@@ -94,4 +102,3 @@
new_class.template = ViewPageTemplateFile(template)
finally:
_context.actions.append(action)
-
More information about the checkins
mailing list