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
916da7f9
Commit
916da7f9
authored
Mar 28, 2002
by
Casey Duncan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge ZClass constructor spruce up changes
parent
35f0fe58
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
54 deletions
+37
-54
doc/CHANGES.txt
doc/CHANGES.txt
+4
-0
lib/python/Products/ZCatalog/__init__.py
lib/python/Products/ZCatalog/__init__.py
+2
-2
lib/python/ZClasses/ZClass.py
lib/python/ZClasses/ZClass.py
+31
-52
No files found.
doc/CHANGES.txt
View file @
916da7f9
...
...
@@ -8,6 +8,10 @@ Zope Changes
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
specify the path to the default method that the publisher calls
when the object is published. The default for objects not defining
...
...
lib/python/Products/ZCatalog/__init__.py
View file @
916da7f9
...
...
@@ -13,13 +13,13 @@
"""ZCatalog product"""
import
ZCatalog
,
Catalog
,
CatalogAwareness
,
ZClasses
import
ZCatalog
,
Catalog
,
Catalog
Path
Awareness
,
ZClasses
from
Products.PluginIndexes.TextIndex
import
Vocabulary
from
ZClasses
import
createZClassForBase
createZClassForBase
(
ZCatalog
.
ZCatalog
,
globals
()
,
'ZCatalogBase'
,
'ZCatalog'
)
createZClassForBase
(
CatalogAwareness
.
CatalogAware
,
globals
()
createZClassForBase
(
Catalog
Path
Awareness
.
CatalogAware
,
globals
()
,
'CatalogAwareBase'
,
'CatalogAware'
)
def
initialize
(
context
):
...
...
lib/python/ZClasses/ZClass.py
View file @
916da7f9
...
...
@@ -19,6 +19,7 @@ from ZPublisher.mapply import mapply
from
ExtensionClass
import
Base
from
App.FactoryDispatcher
import
FactoryDispatcher
from
ComputedAttribute
import
ComputedAttribute
from
Products.PythonScripts.PythonScript
import
PythonScript
import
webdav.Collection
import
marshal
...
...
@@ -153,11 +154,9 @@ def manage_addZClass(self, id, title='', baseclasses=[],
id
+
' constructor input form'
,
addFormDefault
%
{
'id'
:
id
,
'meta_type'
:
meta_type
},
)
self
.
manage_addDTMLMethod
(
id
+
'_add'
,
id
+
' constructor'
,
addDefault
%
{
'id'
:
id
},
)
constScript
=
PythonScript
(
id
+
'_add'
)
constScript
.
write
(
addDefault
%
{
'id'
:
id
,
'title'
:
id
+
' constructor'
})
self
.
_setObject
(
constScript
.
getId
(),
constScript
)
self
.
manage_addPermission
(
id
+
'_add_permission'
,
id
+
' constructor permission'
,
...
...
@@ -705,51 +704,31 @@ addFormDefault="""<HTML>
</body></html>
"""
addDefault
=
"""<HTML>
<HEAD><TITLE>Add %(id)s</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<dtml-comment> We add the new object by calling the class in
a with tag. Not only does this get the thing
added, it adds the new thing's attributes to
the DTML name space, so we can call methods
to initialize the object.
</dtml-comment>
<dtml-with "%(id)s.createInObjectManager(REQUEST['id'], REQUEST)">
<dtml-comment>
You can add code that modifies the new instance here.
For example, if you have a property sheet that you want to update
from form values, you can call it here:
<dtml-call "propertysheets.Basic.manage_editProperties(
REQUEST)">
</dtml-comment>
</dtml-with>
<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>
addDefault
=
"""## Script (Python) "%(id)s_add"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=redirect=1
##title=%(title)s
##
# Add a new instance of the ZClass
request = context.REQUEST
instance = container.%(id)s.createInObjectManager(request['id'], request)
# *****************************************************************
# Perform any initialization of the new instance here.
# For example, to update a property sheet named "Basic" from the
# form values, uncomment the following line of code:
# instance.propertysheets.Basic.manage_editProperties(request)
# *****************************************************************
if redirect:
# redirect to the management view of the instance's container
request.RESPONSE.redirect(instance.aq_parent.absolute_url() + '/manage_main')
else:
# If we aren't supposed to redirect (ie, we are called from a script)
# then just return the ZClass instance to the caller
return instance
"""
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