Commit 5220ac16 authored by Jim Fulton's avatar Jim Fulton

Changed to support new Python product registry mechanism

parent 0a4ef9a5
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''Application support __doc__='''Application support
$Id: Application.py,v 1.96 1999/03/26 19:50:37 brian Exp $''' $Id: Application.py,v 1.97 1999/03/30 18:09:33 jim Exp $'''
__version__='$Revision: 1.96 $'[11:-2] __version__='$Revision: 1.97 $'[11:-2]
import Globals,Folder,os,regex,sys,App.Product, App.ProductRegistry, misc_ import Globals,Folder,os,regex,sys,App.Product, App.ProductRegistry, misc_
...@@ -101,6 +101,9 @@ from Globals import Persistent ...@@ -101,6 +101,9 @@ from Globals import Persistent
from FindSupport import FindSupport from FindSupport import FindSupport
from urllib import quote from urllib import quote
from cStringIO import StringIO from cStringIO import StringIO
from AccessControl.PermissionRole import PermissionRole
from App.ProductContext import ProductContext
from misc_ import Misc_
_standard_error_msg='''\ _standard_error_msg='''\
...@@ -417,23 +420,33 @@ def install_products(app): ...@@ -417,23 +420,33 @@ def install_products(app):
product=__import__("Products.%s" % product_name, product=__import__("Products.%s" % product_name,
global_dict, global_dict, silly) global_dict, global_dict, silly)
# Set up dynamic project information.
productObject=App.Product.initializeProduct(
product, product_name, package_dir, app)
pgetattr(product, 'initialize', lambda context: None)(
ProductContext(productObject, app, product))
permissions={} permissions={}
new_permissions={} new_permissions={}
for permission, names in pgetattr(product, '__ac_permissions__', ()): for p in pgetattr(product, '__ac_permissions__', ()):
permission, names, default = (tuple(p)+('Manager',))[:3]
if names: if names:
for name in names: permissions[name]=permission for name in names:
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) if product_name=='OFSP': meta_types.insert(0,meta_type)
else: meta_types.append(meta_type) else: meta_types.append(meta_type)
name=meta_type['name']
for name,method in pgetattr(product, 'methods', {}).items(): 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__': continue # Just setting roles if name[-9:]!='__roles__': # not Just setting roles
if (permissions.has_key(name) and if (permissions.has_key(name) and
not folder_permissions.has_key(permissions[name])): not folder_permissions.has_key(permissions[name])):
permission=permissions[name] permission=permissions[name]
...@@ -454,9 +467,6 @@ def install_products(app): ...@@ -454,9 +467,6 @@ def install_products(app):
if type(misc_) is DictType: misc_=Misc_(product_name, misc_) if type(misc_) is DictType: misc_=Misc_(product_name, misc_)
Application.misc_.__dict__[product_name]=misc_ Application.misc_.__dict__[product_name]=misc_
# Set up dynamic project information.
App.Product.initializeProduct(product, product_name, package_dir, app)
get_transaction().note('Installed product '+product_name) get_transaction().note('Installed product '+product_name)
get_transaction().commit() get_transaction().commit()
...@@ -474,15 +484,3 @@ def pgetattr(product, name, default=install_products, __init__=0): ...@@ -474,15 +484,3 @@ def pgetattr(product, name, default=install_products, __init__=0):
if default is not install_products: return default if default is not install_products: return default
raise AttributeError, name raise AttributeError, name
class Misc_:
"Miscellaneous product information"
__roles__=None
def __init__(self, name, dict):
self._d=dict
self.__name__=name
def __str__(self): return self.__name__
def __getitem__(self, name): return self._d[name]
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""DTML Document objects.""" """DTML Document objects."""
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import HTML, HTMLFile, MessageDialog from Globals import HTML, HTMLFile, MessageDialog
...@@ -192,7 +192,7 @@ This is the <!--#var id--> Document. ...@@ -192,7 +192,7 @@ This is the <!--#var id--> Document.
addForm=HTMLFile('documentAdd', globals()) addForm=HTMLFile('documentAdd', globals())
def add(self, id, title='', file='', REQUEST=None, submit=None): def addDTMLDocument(self, id, title='', file='', REQUEST=None, submit=None):
"""Add a DTML Document object with the contents of file. If """Add a DTML Document object with the contents of file. If
'file' is empty, default document text is used. 'file' is empty, default document text is used.
""" """
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""DTML Method objects.""" """DTML Method objects."""
__version__='$Revision: 1.12 $'[11:-2] __version__='$Revision: 1.13 $'[11:-2]
from Globals import HTML, HTMLFile, MessageDialog from Globals import HTML, HTMLFile, MessageDialog
from string import join,split,strip,rfind,atoi,lower from string import join,split,strip,rfind,atoi,lower
...@@ -101,7 +101,6 @@ class DTMLMethod(cDocument, HTML, Acquisition.Implicit, RoleManager, ...@@ -101,7 +101,6 @@ class DTMLMethod(cDocument, HTML, Acquisition.Implicit, RoleManager,
"""DTML Method objects are DocumentTemplate.HTML objects that act """DTML Method objects are DocumentTemplate.HTML objects that act
as methods of their containers.""" as methods of their containers."""
meta_type='DTML Method' meta_type='DTML Method'
icon ='p_/dtmlmethod'
_proxy_roles=() _proxy_roles=()
index_html=None # Prevent accidental acquisition index_html=None # Prevent accidental acquisition
...@@ -359,7 +358,7 @@ the <!--#var title_and_id--> Folder.</P> ...@@ -359,7 +358,7 @@ the <!--#var title_and_id--> Folder.</P>
addForm=HTMLFile('methodAdd', globals()) addForm=HTMLFile('methodAdd', globals())
def add(self, id, title='', file='', REQUEST=None, submit=None): def addDTMLMethod(self, id, title='', file='', REQUEST=None, submit=None):
"""Add a DTML Method object with the contents of file. If """Add a DTML Method object with the contents of file. If
'file' is empty, default document text is used. 'file' is empty, default document text is used.
""" """
...@@ -369,7 +368,8 @@ def add(self, id, title='', file='', REQUEST=None, submit=None): ...@@ -369,7 +368,8 @@ def add(self, id, title='', file='', REQUEST=None, submit=None):
ob.title=title ob.title=title
id=self._setObject(id, ob) id=self._setObject(id, ob)
if REQUEST is not None: if REQUEST is not None:
u=REQUEST['URL1'] if hasattr(self, 'DestinationURL'): u=self.DestinationURL()
else: u=REQUEST['URL1']
if submit==" Add and Edit ": u="%s/%s" % (u,quote(id)) if submit==" Add and Edit ": u="%s/%s" % (u,quote(id))
REQUEST.RESPONSE.redirect(u+'/manage_main') REQUEST.RESPONSE.redirect(u+'/manage_main')
return '' return ''
......
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
############################################################################## ##############################################################################
"""Deprecated - use DTMLMethod""" """Deprecated - use DTMLMethod"""
__version__='$Revision: 1.73 $'[11:-2] __version__='$Revision: 1.74 $'[11:-2]
import DTMLMethod import DTMLMethod
Document=DTMLMethod.DTMLMethod Document=DTMLMethod.DTMLMethod
manage_addDocument=DTMLMethod.add manage_addDocument=DTMLMethod.addDTMLMethod
...@@ -87,9 +87,9 @@ ...@@ -87,9 +87,9 @@
Folders are the basic container objects and are analogous to directories. Folders are the basic container objects and are analogous to directories.
$Id: Folder.py,v 1.74 1999/03/25 15:46:26 jim Exp $""" $Id: Folder.py,v 1.75 1999/03/30 18:09:33 jim Exp $"""
__version__='$Revision: 1.74 $'[11:-2] __version__='$Revision: 1.75 $'[11:-2]
import Globals, SimpleItem, Acquisition, mimetypes, content_types import Globals, SimpleItem, Acquisition, mimetypes, content_types
from Globals import HTMLFile from Globals import HTMLFile
...@@ -131,7 +131,6 @@ class Folder(ObjectManager, PropertyManager, RoleManager, Collection, ...@@ -131,7 +131,6 @@ class Folder(ObjectManager, PropertyManager, RoleManager, Collection,
other Principia objects. other Principia objects.
""" """
meta_type='Folder' meta_type='Folder'
icon ='p_/folder'
_properties=({'id':'title', 'type': 'string'},) _properties=({'id':'title', 'type': 'string'},)
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Image object""" """Image object"""
__version__='$Revision: 1.64 $'[11:-2] __version__='$Revision: 1.65 $'[11:-2]
import Globals, string, struct, mimetypes, content_types import Globals, string, struct, mimetypes, content_types
from Globals import HTMLFile, MessageDialog from Globals import HTMLFile, MessageDialog
...@@ -113,7 +113,6 @@ class File(Persistent,Implicit,PropertyManager, ...@@ -113,7 +113,6 @@ class File(Persistent,Implicit,PropertyManager,
"""A File object is a content object for arbitrary files.""" """A File object is a content object for arbitrary files."""
meta_type='File' meta_type='File'
icon='p_/file'
precondition='' precondition=''
manage_editForm =HTMLFile('fileEdit',globals(),Kind='File',kind='file') manage_editForm =HTMLFile('fileEdit',globals(),Kind='File',kind='file')
...@@ -297,7 +296,6 @@ class Image(File): ...@@ -297,7 +296,6 @@ class Image(File):
that renders an HTML 'IMG' tag. that renders an HTML 'IMG' tag.
""" """
meta_type='Image' meta_type='Image'
icon='p_/image'
height=0 height=0
width=0 width=0
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Property sheets""" """Property sheets"""
__version__='$Revision: 1.33 $'[11:-2] __version__='$Revision: 1.34 $'[11:-2]
import time, string, App.Management, Globals import time, string, App.Management, Globals
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
...@@ -134,6 +134,8 @@ class PropertySheet(Persistent, Implicit): ...@@ -134,6 +134,8 @@ class PropertySheet(Persistent, Implicit):
_properties=() _properties=()
_extensible=1 _extensible=1
icon='p_/Properties_icon'
def property_extensible_schema__(self): return self._extensible def property_extensible_schema__(self): return self._extensible
def __init__(self, id, md=None): def __init__(self, id, md=None):
......
...@@ -9,7 +9,7 @@ You may create a new DTML Document using the form below. ...@@ -9,7 +9,7 @@ You may create a new DTML Document using the form below.
You may also choose to upload an existing html file from your You may also choose to upload an existing html file from your
local computer by clicking the <I>Browse</I> button. local computer by clicking the <I>Browse</I> button.
<FORM ACTION="manage_addDTMLDocument" METHOD="POST" <FORM ACTION="addDTMLDocument" METHOD="POST"
ENCTYPE="multipart/form-data"> ENCTYPE="multipart/form-data">
<TABLE CELLSPACING="2"> <TABLE CELLSPACING="2">
<TR> <TR>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
You may also choose to upload an existing html file from your You may also choose to upload an existing html file from your
local computer by clicking the <I>Browse</I> button. local computer by clicking the <I>Browse</I> button.
<FORM ACTION="manage_addDTMLMethod" METHOD="POST" <FORM ACTION="addDTMLMethod" METHOD="POST"
ENCTYPE="multipart/form-data"> ENCTYPE="multipart/form-data">
<TABLE CELLSPACING="2"> <TABLE CELLSPACING="2">
<TR> <TR>
......
...@@ -97,11 +97,9 @@ class p_: ...@@ -97,11 +97,9 @@ class p_:
image =ImageFile('www/Image_icon.gif', globals()) image =ImageFile('www/Image_icon.gif', globals())
file =ImageFile('www/File_icon.gif', globals()) file =ImageFile('www/File_icon.gif', globals())
dtmldoc=doc=ImageFile('www/dtmldoc.gif', globals()) dtmldoc=doc=ImageFile('www/dtmldoc.gif', globals())
dtmlmethod =ImageFile('www/dtmlmethod.gif', globals())
broken=ImageFile('www/broken.gif', globals()) broken=ImageFile('www/broken.gif', globals())
UserFolder=ImageFile('AccessControl/www/UserFolder_icon.gif')
User_icon =ImageFile('AccessControl/www/User_icon.gif') User_icon =ImageFile('AccessControl/www/User_icon.gif')
locked=ImageFile('www/modified.gif', globals()) locked=ImageFile('www/modified.gif', globals())
...@@ -122,3 +120,17 @@ class p_: ...@@ -122,3 +120,17 @@ class p_:
PyPoweredSmall_Gif=ImageFile('App/www/PythonPoweredSmall.gif') PyPoweredSmall_Gif=ImageFile('App/www/PythonPoweredSmall.gif')
ZopeButton=ImageFile('App/www/zope_button.gif') ZopeButton=ImageFile('App/www/zope_button.gif')
Properties_icon=ImageFile('OFS/www/Properties_icon.gif')
class Misc_:
"Miscellaneous product information"
__roles__=None
def __init__(self, name, dict):
self._d=dict
self.__name__=name
def __str__(self): return self.__name__
def __getitem__(self, name): return self._d[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