Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed Aug 7, 2016
1 parent b625d77 commit 33f72dc
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 97 deletions.
14 changes: 6 additions & 8 deletions src/Zope2/App/ClassFactory.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
##############################################################################
#
# Copyright (c) 2002 Zope Foundation and Contributors.
#
#
# 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
#
#
##############################################################################
"""Zope Framework Class Finder
"""

import OFS.Uninstalled

def ClassFactory(jar, module, name,
_silly=('__doc__',), _globals={},
):

def ClassFactory(jar, module, name, _silly=('__doc__',), _globals={}):
try:
m=__import__(module, _globals, _globals, _silly)
m = __import__(module, _globals, _globals, _silly)
return getattr(m, name)
except:
return OFS.Uninstalled.Broken(jar, None, (module, name))
13 changes: 0 additions & 13 deletions src/Zope2/App/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +0,0 @@
##############################################################################
#
# Copyright (c) 2002 Zope Foundation 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.
#
##############################################################################
38 changes: 20 additions & 18 deletions src/Zope2/App/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,21 @@ def startup():
try:
# Try to use custom storage
try:
m=imp.find_module('custom_zodb',[configuration.testinghome])
m = imp.find_module('custom_zodb', [configuration.testinghome])
except:
m=imp.find_module('custom_zodb',[configuration.instancehome])
m = imp.find_module('custom_zodb', [configuration.instancehome])
except Exception:
# if there is no custom_zodb, use the config file specified databases
DB = dbtab.getDatabase('/', is_root=1)
else:
m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2])
sys.modules['Zope2.custom_zodb']=m
m = imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2])
sys.modules['Zope2.custom_zodb'] = m

# Get the database and join it to the dbtab multidatabase
# FIXME: this uses internal datastructures of dbtab
databases = getattr(dbtab, 'databases', {})
if hasattr(m,'DB'):
DB=m.DB
if hasattr(m, 'DB'):
DB = m.DB
databases.update(getattr(DB, 'databases', {}))
DB.databases = databases
else:
Expand Down Expand Up @@ -173,7 +173,7 @@ def validated_hook(request, user):
class RequestContainer(ExtensionClass.Base):

def __init__(self, r):
self.REQUEST=r
self.REQUEST = r


class ZPublisherExceptionHook:
Expand Down Expand Up @@ -234,8 +234,8 @@ def __call__(self, published, REQUEST, t, v, traceback):
error_log_url = log.raising((t, v, traceback))

if (REQUEST is None or
(getattr(REQUEST.get('RESPONSE', None), '_error_format', '')
!= 'text/html')):
(getattr(REQUEST.get('RESPONSE', None),
'_error_format', '') != 'text/html')):
raise t, v, traceback

# Lookup a view for the exception and render it, then
Expand All @@ -245,7 +245,8 @@ def __call__(self, published, REQUEST, t, v, traceback):
# zope.publisher uses as well.
view = queryMultiAdapter((v, REQUEST), name=u'index.html')
if view is not None:
if IAcquirer.providedBy(view) and IAcquirer.providedBy(published):
if (IAcquirer.providedBy(view) and
IAcquirer.providedBy(published)):
view = view.__of__(published)
else:
view.__parent__ = published
Expand All @@ -262,9 +263,9 @@ def __call__(self, published, REQUEST, t, v, traceback):
return response

if (published is None or published is app or
isinstance(published, list)):
isinstance(published, list)):
# At least get the top-level object
published=app.__bobo_traverse__(REQUEST).__of__(
published = app.__bobo_traverse__(REQUEST).__of__(
RequestContainer(REQUEST))

published = getattr(published, 'im_self', published)
Expand Down Expand Up @@ -312,7 +313,9 @@ def __call__(self, published, REQUEST, t, v, traceback):
zpublisher_exception_hook = ZPublisherExceptionHook()
ac_logger = logging.getLogger('event.AccessControl')

class TransactionsManager:

class TransactionsManager(object):

def begin(self,
# Optimize global var lookups:
transaction=transaction):
Expand Down Expand Up @@ -345,8 +348,8 @@ def recordMetaData(self, object, request,
to_append = (object.__name__,)
object = object.im_self

while object is not None and \
not hasattr(object, 'getPhysicalPath'):
while (object is not None and
not hasattr(object, 'getPhysicalPath')):
if getattr(object, '__name__', None) is None:
object = None
break
Expand All @@ -364,14 +367,13 @@ def recordMetaData(self, object, request,

T = transaction.get()
T.note(path)
auth_user=request_get('AUTHENTICATED_USER',None)
auth_user = request_get('AUTHENTICATED_USER', None)
if auth_user is not None:
auth_folder = aq_parent(auth_user)
if auth_folder is None:
ac_logger.warning(
'A user object of type %s has no aq_parent.',
type(auth_user)
)
type(auth_user))
auth_path = request_get('AUTHENTICATION_PATH')
else:
auth_path = '/'.join(auth_folder.getPhysicalPath()[1:-1])
Expand Down
15 changes: 0 additions & 15 deletions src/Zope2/App/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
##############################################################################
#
# Copyright (c) 2007 Zope Foundation 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.
#
##############################################################################

"""Tests of the Zope2.App package."""
6 changes: 1 addition & 5 deletions src/Zope2/App/tests/testDoomedTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest
import transaction


class DoomedTransactionInManagerTest(unittest.TestCase):

def testDoomedFails(self):
Expand All @@ -31,8 +32,3 @@ def testDoomedSilentInTM(self):
trans = transaction.get()
trans.doom()
tm.commit()

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(DoomedTransactionInManagerTest))
return suite
Loading

0 comments on commit 33f72dc

Please sign in to comment.