Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
514a8f29
Commit
514a8f29
authored
Oct 31, 2005
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- removed old-style product metadata support
- removed all dependencies on that support
parent
34a11562
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
105 deletions
+44
-105
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/OFS/Application.py
lib/python/OFS/Application.py
+2
-53
lib/python/OFS/tests/testProductInit.py
lib/python/OFS/tests/testProductInit.py
+19
-12
lib/python/Products/ZGadflyDA/__init__.py
lib/python/Products/ZGadflyDA/__init__.py
+12
-21
lib/python/Products/ZSQLMethods/__init__.py
lib/python/Products/ZSQLMethods/__init__.py
+8
-19
No files found.
doc/CHANGES.txt
View file @
514a8f29
...
...
@@ -58,6 +58,9 @@ Zope Changes
Other
- OFS Application: Removed support for long deprecated old-style product
metadata in the __init__.py of products.
- ZSQLMethod.manage_main: Moved the error message that warns of a
non-existing or closed database connection next to the Connection ID
dropdown and present it using red to increase its visibility.
...
...
lib/python/OFS/Application.py
View file @
514a8f29
...
...
@@ -734,7 +734,6 @@ def install_product(app, product_dir, product_name, meta_types,
path_join
=
os
.
path
.
join
isdir
=
os
.
path
.
isdir
exists
=
os
.
path
.
exists
DictType
=
type
({})
global_dict
=
globals
()
silly
=
(
'__doc__'
,)
...
...
@@ -755,7 +754,7 @@ def install_product(app, product_dir, product_name, meta_types,
# like icon images.
misc_
=
pgetattr
(
product
,
'misc_'
,
{})
if
misc_
:
if
type
(
misc_
)
is
DictType
:
if
isinstance
(
misc_
,
dict
)
:
misc_
=
Misc_
(
product_name
,
misc_
)
Application
.
misc_
.
__dict__
[
product_name
]
=
misc_
...
...
@@ -770,61 +769,11 @@ def install_product(app, product_dir, product_name, meta_types,
product
,
product_name
,
package_dir
,
app
)
context
=
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.
# Look for an 'initialize' method in the product.
initmethod
=
pgetattr
(
product
,
'initialize'
,
None
)
if
initmethod
is
not
None
:
initmethod
(
context
)
# Support old-style product metadata. Older products may
# define attributes to name their permissions, meta_types,
# constructors, etc.
permissions
=
{}
new_permissions
=
{}
for
p
in
pgetattr
(
product
,
'__ac_permissions__'
,
()):
permission
,
names
,
default
=
(
tuple
(
p
)
+
(
'Manager'
,))[:
3
]
if
names
:
for
name
in
names
:
permissions
[
name
]
=
permission
elif
not
folder_permissions
.
has_key
(
permission
):
new_permissions
[
permission
]
=
()
for
meta_type
in
pgetattr
(
product
,
'meta_types'
,
()):
# Modern product initialization via a ProductContext
# 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
)
if
pname
is
not
None
:
meta_type
[
'permission'
]
=
pname
meta_type
[
'product'
]
=
productObject
.
id
meta_type
[
'visibility'
]
=
'Global'
meta_types
.
append
(
meta_type
)
for
name
,
method
in
pgetattr
(
product
,
'methods'
,
{}).
items
():
if
not
hasattr
(
Folder
.
Folder
,
name
):
setattr
(
Folder
.
Folder
,
name
,
method
)
if
name
[
-
9
:]
!=
'__roles__'
:
# not Just setting roles
if
(
permissions
.
has_key
(
name
)
and
not
folder_permissions
.
has_key
(
permissions
[
name
])):
permission
=
permissions
[
name
]
if
new_permissions
.
has_key
(
permission
):
new_permissions
[
permission
].
append
(
name
)
else
:
new_permissions
[
permission
]
=
[
name
]
if
new_permissions
:
new_permissions
=
new_permissions
.
items
()
for
permission
,
names
in
new_permissions
:
folder_permissions
[
permission
]
=
names
new_permissions
.
sort
()
Folder
.
Folder
.
__ac_permissions__
=
tuple
(
list
(
Folder
.
Folder
.
__ac_permissions__
)
+
new_permissions
)
if
not
doInstall
():
transaction
().
abort
()
else
:
...
...
lib/python/OFS/tests/testProductInit.py
View file @
514a8f29
...
...
@@ -44,16 +44,18 @@ products <<PRODUCTS2>>
# backslashes, the backslashes get treated *as* backslashes instead of as
# string escape codes.
dummy_product_init
=
"""
misc_ = {'a':1}
def amethod(self):
pass
def initialize(context):
f=open(r'%s', 'w')
f.write('didit')
f.close()
misc_ = {'a':1}
def amethod(self):
pass
methods = {'amethod':amethod}
__ac_permissions__ = ( ('aPermission', (), () ), )
meta_types = ( {'name':'grabass', 'action':'amethod'}, )
context.registerClass(
meta_type='grabass',
permission='aPermission',
constructors=(amethod,),
legacy=(amethod,))
"""
def
getSchema
():
...
...
@@ -195,13 +197,18 @@ class TestProductInit( unittest.TestCase ):
self
.
assert_
(
os
.
path
.
exists
(
doneflag
))
# Methods installed into folder
self
.
assert_
(
hasattr
(
Folder
,
'amethod'
))
# __ac_permissions__ put into folder
self
.
assert_
(
(
'aPermission'
,
(),)
in
Folder
.
__ac_permissions__
)
# permission roles put into folder
self
.
assert_
(
hasattr
(
Folder
,
'amethod__roles__'
))
# Products.meta_types updated
self
.
assert_
(
{
'action'
:
'amethod'
,
'product'
:
'abaz'
,
'name'
:
'grabass'
,
'visibility'
:
'Global'
}
in
meta_types
)
self
.
assert_
(
{
'name'
:
'grabass'
,
'action'
:
'manage_addProduct/abaz/amethod'
,
'product'
:
'abaz'
,
'permission'
:
'aPermission'
,
'visibility'
:
'Global'
,
'interfaces'
:
(),
'instance'
:
None
,
'container_filter'
:
None
}
in
Products
.
meta_types
)
def
test_install_products
(
self
):
self
.
makeFakeProducts
()
...
...
lib/python/Products/ZGadflyDA/__init__.py
View file @
514a8f29
...
...
@@ -7,13 +7,13 @@
# 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
# FOR A PARTICULAR PURPOSE
.
#
##############################################################################
__doc__
=
'''Generic Database Adapter Package Registration
"""Generic Database Adapter Package Registration.
$Id$
'''
__version__
=
'$Revision: 1.16 $'
[
11
:
-
2
]
$Id$
"""
import
Globals
,
os
...
...
@@ -34,12 +34,6 @@ for icon in ('table', 'view', 'stable', 'what',
'date'
,
'time'
,
'datetime'
):
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
def
getDA
():
global
DA
...
...
@@ -70,20 +64,17 @@ def manage_addZGadflyConnection(
return
getDA
().
manage_addZGadflyConnection
(
self
,
id
,
title
,
connection
,
check
,
REQUEST
)
methods
=
{
'manage_addZGadflyConnection'
:
manage_addZGadflyConnection
,
'manage_addZGadflyConnectionForm'
:
manage_addZGadflyConnectionForm
,
}
def
initialize
(
context
):
__ac_permissions__
=
(
(
'Add Z Gadfly Database Connections'
,
(
'manage_addZGadflyConnectionForm'
,
'manage_addZGadflyConnection'
)),
context
.
registerClass
(
DA
.
Connection
,
permission
=
'Add Z Gadfly Database Connections'
,
constructors
=
(
manage_addZGadflyConnectionForm
,
manage_addZGadflyConnection
),
legacy
=
(
manage_addZGadflyConnectionForm
,
manage_addZGadflyConnection
),
)
# from App.config import getConfiguration
# j=os.path.join
# d=j(getConfiguration().clienthome,'gadfly')
...
...
lib/python/Products/ZSQLMethods/__init__.py
View file @
514a8f29
...
...
@@ -7,21 +7,19 @@
# 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
# 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.RDB
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
):
context
.
registerClass
(
...
...
@@ -29,6 +27,9 @@ def initialize(context):
permission
=
'Add Database Methods'
,
constructors
=
(
SQL
.
manage_addZSQLMethodForm
,
SQL
.
manage_addZSQLMethod
),
icon
=
'sqlmethod.gif'
,
# XXX: can this permission be removed?
permissions
=
(
'Open/Close Database Connections'
,),
legacy
=
(
SQL
.
SQLConnectionIDs
,)
)
context
.
registerClass
(
...
...
@@ -36,24 +37,12 @@ def initialize(context):
permission
=
'Add Documents, Images, and Files'
,
constructors
=
(
Shared
.
DC
.
ZRDB
.
Search
.
addForm
,
Shared
.
DC
.
ZRDB
.
Search
.
manage_addZSearch
),
legacy
=
(
Shared
.
DC
.
ZRDB
.
Search
.
ZQueryIds
,)
)
context
.
registerHelp
()
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__
=
(
(
'Products.AqueductSQLMethods'
,
'Products.ZSQLMethods'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment