Commit 50085536 authored by 's avatar

- minor code modernization (to make reading the code easier)

parent 404d00a0
...@@ -7,11 +7,14 @@ ...@@ -7,11 +7,14 @@
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
"""Objects providing context for product initialization """Objects providing context for product initialization
$Id$
""" """
from AccessControl.PermissionRole import PermissionRole from AccessControl.PermissionRole import PermissionRole
import Globals, os, OFS.ObjectManager, OFS.misc_, Products import Globals, os, OFS.ObjectManager, OFS.misc_, Products
import AccessControl.Permission import AccessControl.Permission
...@@ -22,7 +25,6 @@ from zLOG import LOG, WARNING ...@@ -22,7 +25,6 @@ from zLOG import LOG, WARNING
import os.path, re import os.path, re
import stat import stat
from DateTime import DateTime from DateTime import DateTime
from types import ListType, TupleType
from Interface.Implements import instancesOfObjectImplements from Interface.Implements import instancesOfObjectImplements
from App.Product import doInstall from App.Product import doInstall
...@@ -101,7 +103,6 @@ class ProductContext: ...@@ -101,7 +103,6 @@ class ProductContext:
app=self.__app app=self.__app
pack=self.__pack pack=self.__pack
initial=constructors[0] initial=constructors[0]
tt=type(())
productObject=self.__prod productObject=self.__prod
pid=productObject.id pid=productObject.id
...@@ -112,11 +113,11 @@ class ProductContext: ...@@ -112,11 +113,11 @@ class ProductContext:
OM=OFS.ObjectManager.ObjectManager OM=OFS.ObjectManager.ObjectManager
if permissions: if permissions:
if type(permissions) is type(''): # You goofed it! if isinstance(permissions, basestring): # You goofed it!
raise TypeError, ('Product context permissions should be a ' raise TypeError, ('Product context permissions should be a '
'list of permissions not a string', permissions) 'list of permissions not a string', permissions)
for p in permissions: for p in permissions:
if type(p) is tt: if isinstance(p, tuple):
p, default= p p, default= p
AccessControl.Permission.registerPermissions( AccessControl.Permission.registerPermissions(
((p, (), default),)) ((p, (), default),))
...@@ -129,7 +130,7 @@ class ProductContext: ...@@ -129,7 +130,7 @@ class ProductContext:
if permission is None: if permission is None:
permission="Add %ss" % (meta_type or instance_class.meta_type) permission="Add %ss" % (meta_type or instance_class.meta_type)
if type(permission) is tt: if isinstance(permission, tuple):
permission, default = permission permission, default = permission
else: else:
default = ('Manager',) default = ('Manager',)
...@@ -140,7 +141,7 @@ class ProductContext: ...@@ -140,7 +141,7 @@ class ProductContext:
############################################################ ############################################################
for method in legacy: for method in legacy:
if type(method) is tt: if isinstance(method, tuple):
name, method = method name, method = method
aliased = 1 aliased = 1
else: else:
...@@ -156,8 +157,10 @@ class ProductContext: ...@@ -156,8 +157,10 @@ class ProductContext:
setattr(OM, method.__name__, method) setattr(OM, method.__name__, method)
setattr(OM, method.__name__+'__roles__', pr) setattr(OM, method.__name__+'__roles__', pr)
if type(initial) is tt: name, initial = initial if isinstance(initial, tuple):
else: name=initial.__name__ name, initial = initial
else:
name = initial.__name__
fd=getattr(pack, '__FactoryDispatcher__', None) fd=getattr(pack, '__FactoryDispatcher__', None)
if fd is None: if fd is None:
...@@ -192,7 +195,8 @@ class ProductContext: ...@@ -192,7 +195,8 @@ class ProductContext:
m[name+'__roles__']=pr m[name+'__roles__']=pr
for method in constructors[1:]: for method in constructors[1:]:
if type(method) is tt: name, method = method if isinstance(method, tuple):
name, method = method
else: else:
name=os.path.split(method.__name__)[-1] name=os.path.split(method.__name__)[-1]
if not productObject.__dict__.has_key(name): if not productObject.__dict__.has_key(name):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment