Commit 6e6e3eef authored by 's avatar

Merged fix for product initialization from 2.2 branch

parent cd556920
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.131 2000/08/02 17:31:54 brian Exp $''' $Id: Application.py,v 1.132 2000/08/10 14:22:48 brian Exp $'''
__version__='$Revision: 1.131 $'[11:-2] __version__='$Revision: 1.132 $'[11:-2]
import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_ import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
import time, traceback, os, string, Products import time, traceback, os, string, Products
...@@ -485,49 +485,52 @@ def install_products(app): ...@@ -485,49 +485,52 @@ def install_products(app):
initmethod=pgetattr(product, 'initialize', None) initmethod=pgetattr(product, 'initialize', None)
if initmethod is not None: if initmethod is not None:
initmethod(context) initmethod(context)
else:
permissions={} # Support old-style product metadata. Older products may
new_permissions={} # define attributes to name their permissions, meta_types,
for p in pgetattr(product, '__ac_permissions__', ()): # constructors, etc.
permission, names, default = ( permissions={}
tuple(p)+('Manager',))[:3] new_permissions={}
if names: for p in pgetattr(product, '__ac_permissions__', ()):
for name in names: permission, names, default = (
permissions[name]=permission tuple(p)+('Manager',))[:3]
elif not folder_permissions.has_key(permission): if names:
new_permissions[permission]=() for name in names:
permissions[name]=permission
for meta_type in pgetattr(product, 'meta_types', ()): elif not folder_permissions.has_key(permission):
# Modern product initialization via a ProductContext new_permissions[permission]=()
# adds 'product' and 'permission' keys to the meta_type
# mapping. We have to add these here for old products. for meta_type in pgetattr(product, 'meta_types', ()):
pname=permissions.get(meta_type['action'], None) # Modern product initialization via a ProductContext
if pname is not None: # adds 'product' and 'permission' keys to the meta_type
meta_type['permission']=pname # mapping. We have to add these here for old products.
meta_type['product']=productObject.id pname=permissions.get(meta_type['action'], None)
meta_types.append(meta_type) if pname is not None:
meta_type['permission']=pname
for name,method in pgetattr( meta_type['product']=productObject.id
product, 'methods', {}).items(): meta_types.append(meta_type)
if not hasattr(Folder, name):
setattr(Folder, name, method) for name,method in pgetattr(
if name[-9:]!='__roles__': # not Just setting roles product, 'methods', {}).items():
if (permissions.has_key(name) and if not hasattr(Folder, name):
not folder_permissions.has_key( setattr(Folder, name, method)
permissions[name])): if name[-9:]!='__roles__': # not Just setting roles
permission=permissions[name] if (permissions.has_key(name) and
if new_permissions.has_key(permission): not folder_permissions.has_key(
new_permissions[permission].append(name) permissions[name])):
else: permission=permissions[name]
new_permissions[permission]=[name] if new_permissions.has_key(permission):
new_permissions[permission].append(name)
if new_permissions: else:
new_permissions=new_permissions.items() new_permissions[permission]=[name]
for permission, names in new_permissions:
folder_permissions[permission]=names if new_permissions:
new_permissions.sort() new_permissions=new_permissions.items()
Folder.__dict__['__ac_permissions__']=tuple( for permission, names in new_permissions:
list(Folder.__ac_permissions__)+new_permissions) folder_permissions[permission]=names
new_permissions.sort()
Folder.__dict__['__ac_permissions__']=tuple(
list(Folder.__ac_permissions__)+new_permissions)
if os.environ.get('ZEO_CLIENT',''): if os.environ.get('ZEO_CLIENT',''):
# we don't want to install products from clients! # we don't want to install products from clients!
......
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