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

Changed to support new Python product registry mechanism

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