Commit 26632704 authored by 's avatar

- marked old-style product metadata support as deprecated

- removed all dependencies on that support
parent 65060456
...@@ -22,7 +22,14 @@ Zope Changes ...@@ -22,7 +22,14 @@ Zope Changes
- Collector #1233: port ZOPE_CONFIG patch from Zope 2.7 to Zope 2.8 - Collector #1233: port ZOPE_CONFIG patch from Zope 2.7 to Zope 2.8
Zope 2.8.5 (unreleased)
Bugs Fixed
- OFS Application: While deprecated since years, old-style product
metadata in the __init__.py did not show deprecation warnings. Added
warnings and converted ZGadflyDA/__init__.py and
ZSQLMethods/__init__.py to use registerClass instead.
Zope 2.8.4 (2005/10/26) Zope 2.8.4 (2005/10/26)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# 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.
# #
############################################################################## ##############################################################################
"""Application support """Application support
...@@ -18,6 +18,7 @@ $Id$ ...@@ -18,6 +18,7 @@ $Id$
import os, sys, traceback import os, sys, traceback
from cgi import escape from cgi import escape
from StringIO import StringIO from StringIO import StringIO
from warnings import warn
import Globals, Products, App.Product, App.ProductRegistry, misc_ import Globals, Products, App.Product, App.ProductRegistry, misc_
import transaction import transaction
...@@ -401,7 +402,7 @@ class AppInitializer: ...@@ -401,7 +402,7 @@ class AppInitializer:
default_period_secs = 20 default_period_secs = 20
default_timeout_mins = 20 default_timeout_mins = 20
limit = getattr(config, 'maximum_number_of_session_objects', limit = getattr(config, 'maximum_number_of_session_objects',
default_limit) default_limit)
timeout_spec = getattr(config, 'session_timeout_minutes', timeout_spec = getattr(config, 'session_timeout_minutes',
default_timeout_mins) default_timeout_mins)
...@@ -777,6 +778,13 @@ def install_product(app, product_dir, product_name, meta_types, ...@@ -777,6 +778,13 @@ def install_product(app, product_dir, product_name, meta_types,
# constructors, etc. # constructors, etc.
permissions={} permissions={}
new_permissions={} new_permissions={}
if pgetattr(product, '__ac_permissions__', None) is not None:
warn('__init__.py of %s has a long deprecated '
'\'__ac_permissions__\' attribute. '
'\'__ac_permissions__\' will be ignored by '
'install_product in Zope 2.9. Please use registerClass '
'instead.' % product.__name__,
DeprecationWarning)
for p in pgetattr(product, '__ac_permissions__', ()): for p in pgetattr(product, '__ac_permissions__', ()):
permission, names, default = ( permission, names, default = (
tuple(p)+('Manager',))[:3] tuple(p)+('Manager',))[:3]
...@@ -786,6 +794,12 @@ def install_product(app, product_dir, product_name, meta_types, ...@@ -786,6 +794,12 @@ def install_product(app, product_dir, product_name, meta_types,
elif not folder_permissions.has_key(permission): elif not folder_permissions.has_key(permission):
new_permissions[permission]=() new_permissions[permission]=()
if pgetattr(product, 'meta_types', None) is not None:
warn('__init__.py of %s has a long deprecated \'meta_types\' '
'attribute. \'meta_types\' will be ignored by '
'install_product in Zope 2.9. Please use registerClass '
'instead.' % product.__name__,
DeprecationWarning)
for meta_type in pgetattr(product, 'meta_types', ()): for meta_type in pgetattr(product, 'meta_types', ()):
# Modern product initialization via a ProductContext # Modern product initialization via a ProductContext
# adds 'product' and 'permission' keys to the meta_type # adds 'product' and 'permission' keys to the meta_type
...@@ -797,6 +811,12 @@ def install_product(app, product_dir, product_name, meta_types, ...@@ -797,6 +811,12 @@ def install_product(app, product_dir, product_name, meta_types,
meta_type['visibility'] = 'Global' meta_type['visibility'] = 'Global'
meta_types.append(meta_type) meta_types.append(meta_type)
if pgetattr(product, 'methods', None) is not None:
warn('__init__.py of %s has a long deprecated \'methods\' '
'attribute. \'methods\' will be ignored by '
'install_product in Zope 2.9. Please use registerClass '
'instead.' % product.__name__,
DeprecationWarning)
for name,method in pgetattr( for name,method in pgetattr(
product, 'methods', {}).items(): product, 'methods', {}).items():
if not hasattr(Folder.Folder, name): if not hasattr(Folder.Folder, name):
......
...@@ -44,16 +44,18 @@ products <<PRODUCTS2>> ...@@ -44,16 +44,18 @@ products <<PRODUCTS2>>
# backslashes, the backslashes get treated *as* backslashes instead of as # backslashes, the backslashes get treated *as* backslashes instead of as
# string escape codes. # string escape codes.
dummy_product_init = """ dummy_product_init = """
misc_ = {'a':1}
def amethod(self):
pass
def initialize(context): def initialize(context):
f=open(r'%s', 'w') f=open(r'%s', 'w')
f.write('didit') f.write('didit')
f.close() f.close()
misc_ = {'a':1} context.registerClass(
def amethod(self): meta_type='grabass',
pass permission='aPermission',
methods = {'amethod':amethod} constructors=(amethod,),
__ac_permissions__ = ( ('aPermission', (), () ), ) legacy=(amethod,))
meta_types = ( {'name':'grabass', 'action':'amethod'}, )
""" """
def getSchema(): def getSchema():
...@@ -195,13 +197,18 @@ class TestProductInit( unittest.TestCase ): ...@@ -195,13 +197,18 @@ class TestProductInit( unittest.TestCase ):
self.assert_(os.path.exists(doneflag)) self.assert_(os.path.exists(doneflag))
# Methods installed into folder # Methods installed into folder
self.assert_(hasattr(Folder, 'amethod')) self.assert_(hasattr(Folder, 'amethod'))
# __ac_permissions__ put into folder # permission roles put into folder
self.assert_( ('aPermission', (),) in self.assert_(hasattr(Folder, 'amethod__roles__'))
Folder.__ac_permissions__)
# Products.meta_types updated # Products.meta_types updated
self.assert_( {'action': 'amethod', 'product': 'abaz', self.assert_( {'name': 'grabass',
'name': 'grabass', 'visibility': 'Global'} 'action': 'manage_addProduct/abaz/amethod',
in meta_types) 'product': 'abaz',
'permission': 'aPermission',
'visibility': 'Global',
'interfaces': (),
'instance': None,
'container_filter': None}
in Products.meta_types)
def test_install_products(self): def test_install_products(self):
self.makeFakeProducts() self.makeFakeProducts()
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
# 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.
# #
############################################################################## ##############################################################################
__doc__='''Generic Database Adapter Package Registration """Generic Database Adapter Package Registration.
$Id$''' $Id$
__version__='$Revision: 1.16 $'[11:-2] """
import Globals, os import Globals, os
...@@ -34,12 +34,6 @@ for icon in ('table', 'view', 'stable', 'what', ...@@ -34,12 +34,6 @@ for icon in ('table', 'view', 'stable', 'what',
'date','time','datetime'): 'date','time','datetime'):
misc_[icon]=Globals.ImageFile('icons/%s.gif' % icon, globals()) misc_[icon]=Globals.ImageFile('icons/%s.gif' % icon, globals())
meta_types=(
{'name':'Z %s Database Connection' % database_type,
'action':'manage_addZ%sConnectionForm' % database_type,
},
)
DA=None DA=None
def getDA(): def getDA():
global DA global DA
...@@ -70,20 +64,17 @@ def manage_addZGadflyConnection( ...@@ -70,20 +64,17 @@ def manage_addZGadflyConnection(
return getDA().manage_addZGadflyConnection( return getDA().manage_addZGadflyConnection(
self, id, title, connection, check, REQUEST) self, id, title, connection, check, REQUEST)
methods={ def initialize(context):
'manage_addZGadflyConnection':
manage_addZGadflyConnection,
'manage_addZGadflyConnectionForm':
manage_addZGadflyConnectionForm,
}
__ac_permissions__=( context.registerClass(
('Add Z Gadfly Database Connections', DA.Connection,
('manage_addZGadflyConnectionForm', permission='Add Z Gadfly Database Connections',
'manage_addZGadflyConnection')), constructors=(manage_addZGadflyConnectionForm,
manage_addZGadflyConnection),
legacy=(manage_addZGadflyConnectionForm,
manage_addZGadflyConnection),
) )
# from App.config import getConfiguration # from App.config import getConfiguration
# j=os.path.join # j=os.path.join
# d=j(getConfiguration().clienthome,'gadfly') # d=j(getConfiguration().clienthome,'gadfly')
......
...@@ -7,21 +7,19 @@ ...@@ -7,21 +7,19 @@
# 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.
# #
############################################################################## ##############################################################################
__doc__='''SQL Method Product """SQL Method Product.
$Id$
"""
$Id$'''
__version__='$Revision: 1.18 $'[11:-2]
import Shared.DC.ZRDB.Search, Shared.DC.ZRDB.Aqueduct, SQL import Shared.DC.ZRDB.Search, Shared.DC.ZRDB.Aqueduct, SQL
import Shared.DC.ZRDB.RDB import Shared.DC.ZRDB.RDB
import Shared.DC.ZRDB.sqlvar, Shared.DC.ZRDB.sqlgroup, Shared.DC.ZRDB.sqltest import Shared.DC.ZRDB.sqlvar, Shared.DC.ZRDB.sqlgroup, Shared.DC.ZRDB.sqltest
# This is the new way to initialize products. It is hoped
# that this more direct mechanism will be more understandable.
def initialize(context): def initialize(context):
context.registerClass( context.registerClass(
...@@ -29,6 +27,9 @@ def initialize(context): ...@@ -29,6 +27,9 @@ def initialize(context):
permission='Add Database Methods', permission='Add Database Methods',
constructors=(SQL.manage_addZSQLMethodForm, SQL.manage_addZSQLMethod), constructors=(SQL.manage_addZSQLMethodForm, SQL.manage_addZSQLMethod),
icon='sqlmethod.gif', icon='sqlmethod.gif',
# XXX: can this permission be removed?
permissions=('Open/Close Database Connections',),
legacy=(SQL.SQLConnectionIDs,)
) )
context.registerClass( context.registerClass(
...@@ -36,24 +37,12 @@ def initialize(context): ...@@ -36,24 +37,12 @@ def initialize(context):
permission='Add Documents, Images, and Files', permission='Add Documents, Images, and Files',
constructors=(Shared.DC.ZRDB.Search.addForm, constructors=(Shared.DC.ZRDB.Search.addForm,
Shared.DC.ZRDB.Search.manage_addZSearch), Shared.DC.ZRDB.Search.manage_addZSearch),
legacy=(Shared.DC.ZRDB.Search.ZQueryIds,)
) )
context.registerHelp() context.registerHelp()
context.registerHelpTitle('Zope Help') context.registerHelpTitle('Zope Help')
methods={
# We still need this one, at least for now, for both editing and
# adding. Ugh.
'SQLConnectionIDs': SQL.SQLConnectionIDs,
# Oh please!
'ZQueryIds': Shared.DC.ZRDB.Search.ZQueryIds,
}
__ac_permissions__=(
# Ugh. We should get rid of this, but we'll have to revisit connections
('Open/Close Database Connections', ()),
)
__module_aliases__=( __module_aliases__=(
('Products.AqueductSQLMethods','Products.ZSQLMethods'), ('Products.AqueductSQLMethods','Products.ZSQLMethods'),
......
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