Commit af746749 authored by 's avatar

Merged fix for products with old-style initialization not being properly

filtered by permission in the filtered add list.
parent 499caee1
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.130 2000/07/28 15:50:05 jim Exp $''' $Id: Application.py,v 1.131 2000/08/02 17:31:54 brian Exp $'''
__version__='$Revision: 1.130 $'[11:-2] __version__='$Revision: 1.131 $'[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
...@@ -408,6 +408,7 @@ def import_products(_st=type('')): ...@@ -408,6 +408,7 @@ def import_products(_st=type('')):
try: modules[pname].__import_error__=f try: modules[pname].__import_error__=f
except: pass except: pass
def install_products(app): def install_products(app):
# Install a list of products into the basic folder class, so # Install a list of products into the basic folder class, so
# that all folders know about top-level objects, aka products # that all folders know about top-level objects, aka products
...@@ -439,8 +440,12 @@ def install_products(app): ...@@ -439,8 +440,12 @@ def install_products(app):
product_names.sort() product_names.sort()
for product_name in product_names: for product_name in product_names:
# For each product, we will import it and try to call the
if done.has_key(product_name): continue # intialize() method in the product __init__ module. If
# the method doesnt exist, we put the old-style information
# together and do a default initialization.
if done.has_key(product_name):
continue
done[product_name]=1 done[product_name]=1
package_dir=path_join(product_dir, product_name) package_dir=path_join(product_dir, product_name)
...@@ -449,41 +454,61 @@ def install_products(app): ...@@ -449,41 +454,61 @@ def install_products(app):
if not exists(path_join(package_dir, '__init__.py')): if not exists(path_join(package_dir, '__init__.py')):
if not exists(path_join(package_dir, '__init__.pyc')): if not exists(path_join(package_dir, '__init__.pyc')):
continue continue
try: try:
product=__import__("Products.%s" % product_name, product=__import__("Products.%s" % product_name,
global_dict, global_dict, silly) global_dict, global_dict, silly)
# Install items into the misc_ namespace, used by products
# and the framework itself to store common static resources
# like icon images.
misc_=pgetattr(product, 'misc_', {}) misc_=pgetattr(product, 'misc_', {})
if misc_: if misc_:
if type(misc_) is DictType: if type(misc_) is DictType:
misc_=Misc_(product_name, misc_) misc_=Misc_(product_name, misc_)
Application.misc_.__dict__[product_name]=misc_ Application.misc_.__dict__[product_name]=misc_
# Set up dynamic project information. # Here we create a ProductContext object which contains
# information about the product and provides an interface
# for registering things like classes and help topics that
# should be associated with that product. Products are
# expected to implement a method named 'initialize' in
# their __init__.py that takes the ProductContext as an
# argument.
productObject=App.Product.initializeProduct( productObject=App.Product.initializeProduct(
product, product_name, package_dir, app) product, product_name, package_dir, app)
context=ProductContext(productObject, app, product)
pgetattr(product, 'initialize', lambda context: None)(
ProductContext(productObject, app, product)) # Look for an 'initialize' method in the product. If it does
# not exist, then this is an old product that has never been
# updated. In that case, we will analyze the product and
# build up enough information to do initialization manually.
initmethod=pgetattr(product, 'initialize', None)
if initmethod is not None:
initmethod(context)
else:
permissions={} permissions={}
new_permissions={} new_permissions={}
for p in pgetattr(product, '__ac_permissions__', ()): for p in pgetattr(product, '__ac_permissions__', ()):
permission, names, default = (tuple(p)+('Manager',))[:3] permission, names, default = (
tuple(p)+('Manager',))[:3]
if names: if names:
for name in names: for name in names:
permissions[name]=permission permissions[name]=permission
elif not folder_permissions.has_key(permission): elif not folder_permissions.has_key(permission):
new_permissions[permission]=() new_permissions[permission]=()
for meta_type in pgetattr(product, 'meta_types', ()): for meta_type in pgetattr(product, 'meta_types', ()):
if product_name=='OFSP': meta_types.insert(0,meta_type) # Modern product initialization via a ProductContext
else: meta_types.append(meta_type) # adds 'product' and 'permission' keys to the meta_type
# mapping. We have to add these here for old products.
pname=permissions.get(meta_type['action'], None)
for name,method in pgetattr(product, 'methods', {}).items(): if pname is not None:
meta_type['permission']=pname
meta_type['product']=productObject.id
meta_types.append(meta_type)
for name,method in pgetattr(
product, 'methods', {}).items():
if not hasattr(Folder, name): if not hasattr(Folder, name):
setattr(Folder, name, method) setattr(Folder, name, method)
if name[-9:]!='__roles__': # not Just setting roles if name[-9:]!='__roles__': # not Just setting roles
......
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