Commit 916da7f9 authored by Casey Duncan's avatar Casey Duncan

Merge ZClass constructor spruce up changes

parent 35f0fe58
...@@ -8,6 +8,10 @@ Zope Changes ...@@ -8,6 +8,10 @@ Zope Changes
new Features: new Features:
- ZClasses now use a python script as their constructor method
instead of a DTML method. Also, ZClasses inherit from
CatalogPathAwareness now instead of CatalogAwareness.
- added browser_default hook to ZPublisher. This allows objects to - added browser_default hook to ZPublisher. This allows objects to
specify the path to the default method that the publisher calls specify the path to the default method that the publisher calls
when the object is published. The default for objects not defining when the object is published. The default for objects not defining
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
"""ZCatalog product""" """ZCatalog product"""
import ZCatalog, Catalog, CatalogAwareness, ZClasses import ZCatalog, Catalog, CatalogPathAwareness, ZClasses
from Products.PluginIndexes.TextIndex import Vocabulary from Products.PluginIndexes.TextIndex import Vocabulary
from ZClasses import createZClassForBase from ZClasses import createZClassForBase
createZClassForBase( ZCatalog.ZCatalog , globals() createZClassForBase( ZCatalog.ZCatalog , globals()
, 'ZCatalogBase', 'ZCatalog' ) , 'ZCatalogBase', 'ZCatalog' )
createZClassForBase( CatalogAwareness.CatalogAware, globals() createZClassForBase( CatalogPathAwareness.CatalogAware, globals()
, 'CatalogAwareBase', 'CatalogAware' ) , 'CatalogAwareBase', 'CatalogAware' )
def initialize(context): def initialize(context):
......
...@@ -19,6 +19,7 @@ from ZPublisher.mapply import mapply ...@@ -19,6 +19,7 @@ from ZPublisher.mapply import mapply
from ExtensionClass import Base from ExtensionClass import Base
from App.FactoryDispatcher import FactoryDispatcher from App.FactoryDispatcher import FactoryDispatcher
from ComputedAttribute import ComputedAttribute from ComputedAttribute import ComputedAttribute
from Products.PythonScripts.PythonScript import PythonScript
import webdav.Collection import webdav.Collection
import marshal import marshal
...@@ -153,11 +154,9 @@ def manage_addZClass(self, id, title='', baseclasses=[], ...@@ -153,11 +154,9 @@ def manage_addZClass(self, id, title='', baseclasses=[],
id+' constructor input form', id+' constructor input form',
addFormDefault % {'id': id, 'meta_type': meta_type}, addFormDefault % {'id': id, 'meta_type': meta_type},
) )
self.manage_addDTMLMethod( constScript = PythonScript(id+'_add')
id+'_add', constScript.write(addDefault % {'id': id, 'title':id+' constructor'})
id+' constructor', self._setObject(constScript.getId(), constScript)
addDefault % {'id': id},
)
self.manage_addPermission( self.manage_addPermission(
id+'_add_permission', id+'_add_permission',
id+' constructor permission', id+' constructor permission',
...@@ -705,51 +704,31 @@ addFormDefault="""<HTML> ...@@ -705,51 +704,31 @@ addFormDefault="""<HTML>
</body></html> </body></html>
""" """
addDefault="""<HTML> addDefault="""## Script (Python) "%(id)s_add"
<HEAD><TITLE>Add %(id)s</TITLE></HEAD> ##bind container=container
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555"> ##bind context=context
##bind namespace=
<dtml-comment> We add the new object by calling the class in ##bind script=script
a with tag. Not only does this get the thing ##bind subpath=traverse_subpath
added, it adds the new thing's attributes to ##parameters=redirect=1
the DTML name space, so we can call methods ##title=%(title)s
to initialize the object. ##
</dtml-comment> # Add a new instance of the ZClass
request = context.REQUEST
<dtml-with "%(id)s.createInObjectManager(REQUEST['id'], REQUEST)"> instance = container.%(id)s.createInObjectManager(request['id'], request)
<dtml-comment> # *****************************************************************
# Perform any initialization of the new instance here.
You can add code that modifies the new instance here. # For example, to update a property sheet named "Basic" from the
# form values, uncomment the following line of code:
For example, if you have a property sheet that you want to update # instance.propertysheets.Basic.manage_editProperties(request)
from form values, you can call it here: # *****************************************************************
<dtml-call "propertysheets.Basic.manage_editProperties( if redirect:
REQUEST)"> # redirect to the management view of the instance's container
request.RESPONSE.redirect(instance.aq_parent.absolute_url() + '/manage_main')
</dtml-comment> else:
# If we aren't supposed to redirect (ie, we are called from a script)
</dtml-with> # then just return the ZClass instance to the caller
return instance
<dtml-comment> Now we need to return something. We do this via
a redirect so that the URL is correct.
Unfortunately, the way we do this depends on
whether we live in a product or in a class.
If we live in a product, we need to use DestinationURL
to decide where to go. If we live in a class,
DestinationURL won't be available, so we use URL2.
</dtml-comment>
<dtml-if DestinationURL>
<dtml-call "RESPONSE.redirect(
DestinationURL+'/manage_workspace')">
<dtml-else>
<dtml-call "RESPONSE.redirect(
URL2+'/manage_workspace')">
</dtml-if>
</body></html>
""" """
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