dtml call for copying items?
Hi Everyone, 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. Here are some snippits: from form: <input type="radio" name="ids:list" value="... from form processor: <!--#call "manage_copyObjects(ids)"--> <!--#call "manage_pasteObjects()"--> <!-- stuff to change the new folder's name... I don't get any error on the copy, but the paste says the clipboard is empty. Any suggestions on how to better/correctly do this? Thanks, Joe Total-off-subject-PS: Anyone got a lead on parts for '76 Alfa Romeo Alfetta Sedan?
Joseph Santaniello wrote:
Hi Everyone,
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. Here are some snippits:
from form:
<input type="radio" name="ids:list" value="...
from form processor:
<!--#call "manage_copyObjects(ids)"--> <!--#call "manage_pasteObjects()"--> <!-- stuff to change the new folder's name...
I don't get any error on the copy, but the paste says the clipboard is empty.
That's because the mechanism works based on cookies. Since there is no browser involved in your code, and no cookie in the original 'REQUEST', pasteObjects say's there clipboard is 'empty'. You would have to dig a bit in the source to find a way around this. Might just involve a combination of DTML calls, buit it might involve some python hacks. Wait.. there is a million to one chance this might work, but I haven't tested it, I just dreamed it up: <dtml-if paste_objects> <dtml-call "manage_pasteObjects()"> <dtml-else> <dtml-call "manage_copyObjects(ids)"> <dtml-if QUERY_STRING> <dtml-call "RESPONSE.redirect(absolute_url() + '&paste_objects=')"> <dtml-else> <dtml-call "RESPONSE.redirect(absolute_url() + '?paste_objects=')"> </dtml-if> </dtml-if> You might need to play with it. -Michel
If that works: Ooh sneaky ;¬) Phil phil@phih.org -----Original Message----- From: michel@digicool.com [mailto:michel@digicool.com] Sent: 10 October 1999 22:40 To: Joseph Santaniello Cc: zope@zope.org Subject: Re: [Zope] dtml call for copying items? Joseph Santaniello wrote:
Hi Everyone,
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. Here are some snippits:
from form:
<input type="radio" name="ids:list" value="...
from form processor:
<!--#call "manage_copyObjects(ids)"--> <!--#call "manage_pasteObjects()"--> <!-- stuff to change the new folder's name...
I don't get any error on the copy, but the paste says the clipboard is empty.
That's because the mechanism works based on cookies. Since there is no browser involved in your code, and no cookie in the original 'REQUEST', pasteObjects say's there clipboard is 'empty'. You would have to dig a bit in the source to find a way around this. Might just involve a combination of DTML calls, buit it might involve some python hacks. Wait.. there is a million to one chance this might work, but I haven't tested it, I just dreamed it up: <dtml-if paste_objects> <dtml-call "manage_pasteObjects()"> <dtml-else> <dtml-call "manage_copyObjects(ids)"> <dtml-if QUERY_STRING> <dtml-call "RESPONSE.redirect(absolute_url() + '&paste_objects=')"> <dtml-else> <dtml-call "RESPONSE.redirect(absolute_url() + '?paste_objects=')"> </dtml-if> </dtml-if> You might need to play with it. -Michel _______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope (Related lists - please, no cross posts or HTML encoding! To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
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 <----------------'
Hallo, On Fri, Oct 15, 1999 at 04:04:58AM +0200, Sascha Matzke wrote:
What should I say, it works good enough for my application and I noticed no drawbacks (yet!).
Peng... Some hours after writing this Mail I've noticed some very big drawbacks. So simply forget it... I now have a python-only solution... def reviewObject(self, id): object = self._getOb(id) self.Review._setObject(id,object) self._delObject(id) It simply moves an object to an defined Folder. But you could easily add something like this. *** Warning, untested code *** def reviewObject(self, id, aq_path_to_target="Review"): object = self._getOb(id) try: target = eval('self.' + aq_path_to_target) target._setOb(id) self._delObject(id) except: catch some exception or not *** Warning, untested code *** 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 <----------------'
Hi Everyone, Thanks for the tips. Here's what eventually I used (and works...): <!--#call "manage_copyObjects(ids, REQUEST, RESPONSE)"--> <!--#call "manage_pasteObjects(REQUEST=REQUEST)"--> Joe
participants (5)
-
Joseph Santaniello -
Michel Pelletier -
Phil Harris -
Sascha Matzke -
Sascha Matzke