[Zope] dtml call for copying items?

Sascha Matzke Sascha Matzke <sascha@bespin.de>
Fri, 15 Oct 1999 04:04:58 +0200


--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii

Hello,

On Sun, Oct 10, 1999 at 06:59:16PM +0200, Joseph Santaniello wrote:
> I'm trying to get some dtml code to copy a folder a user selects from a
> form, but I can't get it to work. 

I've made it ;) (with some little tweaks to get around some traps in
CatalogAwareness.py).

My basic dtml-code to copy one object to another Folder:

<dtml-if "REQUEST.has_key('ids')">
   <dtml-let data="manage_cutObjects(REQUEST['ids'])">
      <dtml-call "Review.manage_pasteObjects(data,REQUEST)">
   </dtml-let>
</dtml-if>

If you use this code you will fall over some things in
CatalogAwareness.py (methode url(), lines 159-162) which require a
valid REQUEST object. 

I added an 
if hasattr(self, 'REQUEST'): (patch include as attachment)
on top of these lines and added a method DestinationURL() to my
class which simply returns the previously saved output from
absolute_url().

What should I say, it works good enough for my application and I
noticed no drawbacks (yet!).

Sascha
-- 
.-> Sascha Matzke - sascha@bespin.de - http://www.bespin.de -.
|   Keine Macht fuer niemand...                              |
|                                       Ton Steine Scherben  |
`-- On this earth for  24 years,    1 days  <----------------'

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Description: Patch
Content-Disposition: attachment; filename="Zope.patch"

--- Zope-2.0.1-src/lib/python/Products/ZCatalog/CatalogAwareness.py.orig	Tue Aug 17 22:36:52 1999
+++ Zope-2.0.1-src/lib/python/Products/ZCatalog/CatalogAwareness.py	Fri Oct 15 04:01:02 1999
@@ -156,10 +156,11 @@
         else: url=self.absolute_url()
         type, uri=ftype(url)
         host, uri=fhost(uri)
-        script_name=self.REQUEST['SCRIPT_NAME']
-        __traceback_info__=(`uri`, `script_name`)
-        if script_name:
-            uri=filter(None, string.split(uri, script_name))[0]
+        if hasattr(self, 'REQUEST'):
+            script_name=self.REQUEST['SCRIPT_NAME']
+            __traceback_info__=(`uri`, `script_name`)
+            if script_name:
+                uri=filter(None, string.split(uri, script_name))[0]
         uri=uri or '/'
         if uri[0]=='/': uri=uri[1:]
         return uri

--PNTmBPCT7hxwcZjr--