How best to copy and paste in pythonscript?
Hi. I am having some strange problems getting copy and paste to work propperly in python script Basically I do: parent.manage_copyObjects([currFold.id], REQUEST) in one script, and: dest_fold.manage_pasteObjects(REQUEST) in another I have tried a lot of variations, and read all that I could goolge about it, but stil it won't work. Could somebody please tell me the "canonical" way of dooing this? Regards Gaute Amundsen
--On 28. August 2006 12:08:16 +0200 Gaute Amundsen <gaute@div.org> wrote:
Hi.
I am having some strange problems getting copy and paste to work propperly in python script
Basically I do:
parent.manage_copyObjects([currFold.id], REQUEST)
in one script, and:
dest_fold.manage_pasteObjects(REQUEST)
in another
I have tried a lot of variations, and read all that I could goolge about it, but stil it won't work.
"still won't work" means what? Please provide a reasonable error description. -aj
--On 28. August 2006 12:08:16 +0200 Gaute Amundsen <gaute@div.org> wrote:
Hi.
I am having some strange problems getting copy and paste to work propperly in python script
Basically I do:
parent.manage_copyObjects([currFold.id], REQUEST)
in one script, and:
dest_fold.manage_pasteObjects(REQUEST)
You must check the APIs carefully. manage_pasteObjects() takes REQUEST as keyword parameter but not as positional parameter. So you must pass is it as keyword parameter! -aj
On Monday 28 August 2006 12:21, Andreas Jung wrote:
--On 28. August 2006 12:08:16 +0200 Gaute Amundsen <gaute@div.org> wrote:
Hi.
I am having some strange problems getting copy and paste to work propperly in python script
Basically I do:
parent.manage_copyObjects([currFold.id], REQUEST)
in one script, and:
dest_fold.manage_pasteObjects(REQUEST)
You must check the APIs carefully. manage_pasteObjects() takes REQUEST as keyword parameter but not as positional parameter. So you must pass is it as keyword parameter!
-aj
So you are saying that parent.manage_copyObjects([currFold.id], REQUEST) is ok. and dest_fold.manage_pasteObjects(REQUEST=context.REQUEST) should be ok? When you mention it, where exactly is the APIs? A search of the zope site for "manage_copyObjects" givs me two largely irrelevant hits. Looking at this for example: http://docs.neuroinf.de/api/plone-api/public/OFS.CopySupport.CopyContainer-c... ( which is one of the first things google throws up ) gives no indication that REQUEST is a keyword parameter. G.
--On 28. August 2006 13:00:59 +0200 Gaute Amundsen <gaute@div.org> wrote:
When you mention it, where exactly is the APIs? A search of the zope site for "manage_copyObjects" givs me two largely irrelevant hits.
- Docfindertab - lib/python/OFS/interfaces.py (!) - lib/python/OFS/CopySupport.py -aj -- ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany Web: www.zopyx.com - Email: info@zopyx.com - Phone +49 - 7071 - 793376 E-Publishing, Python, Zope & Plone development, Consulting
On Monday 28 August 2006 13:16, Andreas Jung wrote:
- Docfindertab - lib/python/OFS/interfaces.py (!) - lib/python/OFS/CopySupport.py
-aj
Excuse me, my oh so knowledgable friend, but it is not at all obious to me, ( or most other readers of this list, I'd wager) what or where "Docfindertab" is. On the zope site perhaps, or maybe on _your_ os? But knowing you a bit by now, me thinks you are infact referring to the source.. Some API doc that! Actually, I am starting to think there should be a big notice on the frontpage of the http://www.zope.org/Documentation/ section saying: "don't bother with this, just read the source" I am sure zopes momentum as a platform would improve greatly, and you would not have to bother answering such stupid questions. G.
--On 28. August 2006 14:00:25 +0200 Gaute Amundsen <gaute@div.org> wrote:
On Monday 28 August 2006 13:16, Andreas Jung wrote:
- Docfindertab - lib/python/OFS/interfaces.py (!) - lib/python/OFS/CopySupport.py
-aj
Excuse me, my oh so knowledgable friend, but it is not at all obious to me, ( or most other readers of this list, I'd wager) what or where "Docfindertab" is.
You might google for Docfindertab and click on the first hit. I think that's a task you can perform on your own?
On the zope site perhaps, or maybe on _your_ os?
?
But knowing you a bit by now, me thinks you are infact referring to the source.. Some API doc that!
Actually, I am starting to think there should be a big notice on the frontpage of the http://www.zope.org/Documentation/ section saying:
"don't bother with this, just read the source"
I am sure zopes momentum as a platform would improve greatly, and you would not have to bother answering such stupid questions.
The documentation situation in Zope 2 land is as it is and it won't change much. And as a Zope developer one should know that APIs are usually documented in interface files (that's why I mentioned them *before* the source code file). -aj
On Monday 28 August 2006 14:06, Andreas Jung wrote:
--On 28. August 2006 14:00:25 +0200 Gaute Amundsen <gaute@div.org> wrote:
On Monday 28 August 2006 13:16, Andreas Jung wrote:
- Docfindertab - lib/python/OFS/interfaces.py (!) - lib/python/OFS/CopySupport.py
-aj
Excuse me, my oh so knowledgable friend, but it is not at all obious to me, ( or most other readers of this list, I'd wager) what or where "Docfindertab" is.
You might google for Docfindertab and click on the first hit. I think that's a task you can perform on your own?
I am not in the habit of installing products on our server just because some self important twat, who could not be bothered to write "try the Docfindertab product", mentions a name that might refer to that product. Now you have spent twise as much time typing the reply, as you would have if you had been clear from the start. Not to mention nurturing my growing desire to switch to ROR at the first oportunity, and demonstrating to potential zope users on the list that asking for help wil just get you insulted. Nice.
On the zope site perhaps, or maybe on _your_ os?
?
But knowing you a bit by now, me thinks you are infact referring to the source.. Some API doc that!
Actually, I am starting to think there should be a big notice on the frontpage of the http://www.zope.org/Documentation/ section saying:
"don't bother with this, just read the source"
I am sure zopes momentum as a platform would improve greatly, and you would not have to bother answering such stupid questions.
The documentation situation in Zope 2 land is as it is and it won't change much. And as a Zope developer one should know that APIs are usually documented in interface files (that's why I mentioned them *before* the source code file).
-aj
On my installaton there is no interfaces.py for OFS, nor for hardly anything else. But never mind, you can spare me you nuggets of wisdom, they are not worth the bother. G.
--On 28. August 2006 14:38:23 +0200 Gaute Amundsen <gaute@div.org> wrote:
On Monday 28 August 2006 14:06, Andreas Jung wrote:
--On 28. August 2006 14:00:25 +0200 Gaute Amundsen <gaute@div.org> wrote:
On Monday 28 August 2006 13:16, Andreas Jung wrote:
- Docfindertab - lib/python/OFS/interfaces.py (!) - lib/python/OFS/CopySupport.py
-aj
Excuse me, my oh so knowledgable friend, but it is not at all obious to me, ( or most other readers of this list, I'd wager) what or where "Docfindertab" is.
You might google for Docfindertab and click on the first hit. I think that's a task you can perform on your own?
I am not in the habit of installing products on our server just because some self important twat, who could not be bothered to write "try the Docfindertab product", mentions a name that might refer to that product.
Now you have spent twise as much time typing the reply, as you would have if you had been clear from the start.
Not to mention nurturing my growing desire to switch to ROR at the first oportunity, and demonstrating to potential zope users on the list that asking for help wil just get you insulted.
You had a bad night? The pointer to the keyword argument and the hints where to look for additional information were perfectly fine. So what was insulting? This list is *not* a professional helpdesk. We answer to questions on a voluntary basis. Even as a newbie (if you are one) you should be able to perform additional investigations on your own. What's wrong with googling for "Docfindertab"? I think we don't have to perform such trivial tasks for you. You expected help for you problem - you got help and the right solution. But speaking for almost all other volunteers on this list: we do except that you do basic investigations on your own initiative.
On my installaton there is no interfaces.py for OFS, nor for hardly anything else.
It's available in the latest Zope 2.9 version. Since you did not provide an version information I could not smell what you're using so I looked into the most current version. Otherwise you can always look at the sources (that's why it is called open-source ; you have the freedom to look at the sources) and "grep -r" is always a perfect tool to find related code parts. -aj
Gaute Amundsen wrote:
Not to mention nurturing my growing desire to switch to ROR at the first oportunity,
Please, just go... one less person who seems to be under the impression they've paid for some kind of support contract by joining this list won't be missed. Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Gaute Amundsen wrote:
Actually, I am starting to think there should be a big notice on the frontpage of the http://www.zope.org/Documentation/ section saying:
"don't bother with this, just read the source"
There's actually some merit to this, anyone mind if I implement? <0.5 wink> Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote:
Gaute Amundsen wrote:
Actually, I am starting to think there should be a big notice on the frontpage of the http://www.zope.org/Documentation/ section saying:
"don't bother with this, just read the source"
There's actually some merit to this, anyone mind if I implement?
All kidding aside, I recently volunteered [1] to put some thought and work into a new documentation section. I've got a few ideas floating in my head and will be posting them on zope-web soon. Zope docs aren't a lost cause. There's lots of stuff out there, we just need to bring it back to zope.org (which requires a zope.org that you can actually work with, of course). Philipp [1] http://www.z3lab.org/sections/blogs/philipp-weitershausen/2006_08_27_sorry-f...
On 8/28/06, Gaute Amundsen <gaute@div.org> wrote:
But knowing you a bit by now, me thinks you are infact referring to the source.. Some API doc that!
Correct. That is some API doc. In fact, you can't get any better than that, as it is always up to date, and to the point. :-) Yeah, I know, when you come from the land of compilers, it takes a bit of getting used to. But the fact is that it works very well.
Actually, I am starting to think there should be a big notice on the frontpage of the http://www.zope.org/Documentation/ section saying:
"don't bother with this, just read the source"
Mmm. Yes. Sarcasm. That makes you look serious.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gaute Amundsen wrote:
On Monday 28 August 2006 12:21, Andreas Jung wrote:
--On 28. August 2006 12:08:16 +0200 Gaute Amundsen <gaute@div.org> wrote:
Hi.
I am having some strange problems getting copy and paste to work propperly in python script
Basically I do:
parent.manage_copyObjects([currFold.id], REQUEST)
in one script, and:
dest_fold.manage_pasteObjects(REQUEST) You must check the APIs carefully. manage_pasteObjects() takes REQUEST as keyword parameter but not as positional parameter. So you must pass is it as keyword parameter!
-aj
So you are saying that
parent.manage_copyObjects([currFold.id], REQUEST)
is ok. and
dest_fold.manage_pasteObjects(REQUEST=context.REQUEST)
should be ok?
When you mention it, where exactly is the APIs? A search of the zope site for "manage_copyObjects" givs me two largely irrelevant hits.
Looking at this for example: http://docs.neuroinf.de/api/plone-api/public/OFS.CopySupport.CopyContainer-c... ( which is one of the first things google throws up )
gives no indication that REQUEST is a keyword parameter.
I think the keyword argument bit is a red herring. The issue here is that the methods you are calling are not really designed to be scripted within the context of a single request: 'manage_copyObjects' sets a cookie in the *response* object, while 'manage_pasteObjects' looks for that cookie in the *request* object. This works fine when used as designed: the cookie from the response gets sent back in the next request, which can then figure out which object(s) to paste. For scripting, you need to capture the result of calling 'manage_copyObjects', which will be the value of the cookie (the "clipboard data"), and then pass it into 'manage_pasteObjects'. E.g.:: cb_data = source.manage_copyObjects(ids=selected) target.manage_pasteObjects(cb_data) In this mode, you don't (and shouldn't) need to pass the request at all. Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE8v29+gerLs4ltQ4RAqQzAKCkSdXNdseAPoXcgRfMlUzMFq76nQCgnXPM sRYlTXImfZ3vEPfVBej4hvo= =6Fdy -----END PGP SIGNATURE-----
Thank you, thank you thank you all! Some actuall helpfull advice, and not snotty riddles! I'll try not to feed the troll next time.
I think the keyword argument bit is a red herring. The issue here is that the methods you are calling are not really designed to be scripted within the context of a single request: 'manage_copyObjects' sets a cookie in the *response* object, while 'manage_pasteObjects' looks for that cookie in the *request* object. This works fine when used as designed: the cookie from the response gets sent back in the next request, which can then figure out which object(s) to paste.
That is what I was trying to do. That is, manage_copyObjects in one script/ page and manage_pasteObjects in another. I have used both in one script before, with the clipboad object, with no problems.
you might pass None as clipboard object and the method will try to get the value from the REQUEST. But in this case you must pass in the REQUEST as keyword parameter and not as positional argument.
I've got to read up on the nuances of keyword vs posissional arguments, I think. I have not gotten around to testing it yet, but it rings true.
But back to the original discussion API vs. implementation. That was not the original discussion, that was your private hobbyhorse.
If you are a frequent reader of this list, you know that AJ's style is to encourage posters to 1) be complete and precise in the questions they post and 2) provide just enough infomration for the poster to discover the answer to his/her post himself. This is an excellent pedagogical strategy but sometimes is frustrating.
I know, I know. Now, I asked a simple question, for wich a complete systems description is superfluous, I indicated that I had done a reasonable amount of homework, and I think that a simple answer would be appropriate. Now if he thinks it is his place to educate me with riddles, and about how I should post my questions, it is perhaps only fitting for me to do a bit of educating in return about how to actually read the question, and show some basic human manners. Whith friends like that, zope sure dont need enemies.
No, it's personal laziness to provide the food bite-size :-)
It is not I'm afraid. As a programmer you well know that this kind of lazyness uppfront brings you more work afterwards. I can only conclude that your ego gratification is more important to you than actually helping. Now if I have the stamina, to keep educating you back, or if I will just go away somewhere quiet and grep the source instead, that remains to be seen I guess :) G.
--On 29. August 2006 10:14:04 +0200 Gaute Amundsen <gaute@div.org> wrote:
If you are a frequent reader of this list, you know that AJ's style is to encourage posters to 1) be complete and precise in the questions they post and 2) provide just enough infomration for the poster to discover the answer to his/her post himself. This is an excellent pedagogical strategy but sometimes is frustrating.
I know, I know. Now, I asked a simple question, for wich a complete systems description is superfluous, I indicated that I had done a reasonable amount of homework, and I think that a simple answer would be appropriate.
My answer to your question was: """ manage_pasteObjects() takes REQUEST as keyword parameter but not as positional parameter. So you must pass is it as keyword parameter! """ This answer is short and simple, isn't it? -aj
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 29 Aug 2006, at 10:14, Gaute Amundsen wrote:
Thank you, thank you thank you all! Some actuall helpfull advice, and not snotty riddles! I'll try not to feed the troll next time.
You need to go take a chill pill. You cannot expect hand-holding or that someone cuts up everything into bite-sized pieces, feeds you and then wipes your chin for you. This list is populated by volunteers. If you need people to wipe your rear end then go pay someone, but don't bother this list with your shitty attitude. jens -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFE8/8KRAx5nvEhZLIRAtNjAJ9jKf1d+kM3RyQLRi1BeN5fg/Vj1wCfaylI 1bMo4QKH8GoFr8RyPRbqYro= =9IbS -----END PGP SIGNATURE-----
Take a look at the actual code. Th API requires a that a clipboard object acquired from the copy be sent to the paste. On Mon, 28 Aug 2006, Gaute Amundsen wrote:
Hi.
I am having some strange problems getting copy and paste to work propperly in python script
Basically I do:
parent.manage_copyObjects([currFold.id], REQUEST)
in one script, and:
dest_fold.manage_pasteObjects(REQUEST)
in another
I have tried a lot of variations, and read all that I could goolge about it, but stil it won't work.
Could somebody please tell me the "canonical" way of dooing this?
Regards
Gaute Amundsen _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
--
--On 28. August 2006 07:24:40 -0700 Dennis Allison <allison@shasta.stanford.edu> wrote:
Take a look at the actual code. Th API requires a that a clipboard object acquired from the copy be sent to the paste.
This is not entirely true. If you look at the code you'll that you might pass None as clipboard object and the method will try to get the value from the REQUEST. But in this case you must pass in the REQUEST as keyword parameter and not as positional argument. But back to the original discussion API vs. implementation..To quote Dieter: Unlike the API documentation which describes how things should be, the Docfinder documentation describes (at least partially) how they really are: complete and precise :-) -aj
AJ -- You are, of course, correct. I wanted Gaute to take a look at the actual code and proceed from there. Docfinder is also a useful approach for learning about the system. Gaute -- If you are a frequent reader of this list, you know that AJ's style is to encourage posters to 1) be complete and precise in the questions they post and 2) provide just enough infomration for the poster to discover the answer to his/her post himself. This is an excellent pedagogical strategy but sometimes is frustrating. On Mon, 28 Aug 2006, Andreas Jung wrote:
--On 28. August 2006 07:24:40 -0700 Dennis Allison <allison@shasta.stanford.edu> wrote:
Take a look at the actual code. Th API requires a that a clipboard object acquired from the copy be sent to the paste.
This is not entirely true. If you look at the code you'll that you might pass None as clipboard object and the method will try to get the value from the REQUEST. But in this case you must pass in the REQUEST as keyword parameter and not as positional argument.
But back to the original discussion API vs. implementation..To quote Dieter: Unlike the API documentation which describes how things should be, the Docfinder documentation describes (at least partially) how they really are: complete and precise :-)
-aj
--
--On 28. August 2006 07:41:03 -0700 Dennis Allison <allison@shasta.stanford.edu> wrote:
AJ --
You are, of course, correct. I wanted Gaute to take a look at the actual code and proceed from there. Docfinder is also a useful approach for learning about the system.
Gaute --
If you are a frequent reader of this list, you know that AJ's style is to encourage posters to 1) be complete and precise in the questions they post and 2) provide just enough infomration for the poster to discover the answer to his/her post himself. This is an excellent pedagogical strategy but sometimes is frustrating.
No, it's personal laziness to provide the food bite-size :-) Andreas
Andreas -- Take the compliment. Either way, you have been a great resource for me in the past and will, I hope, continue to be so in the future. On Mon, 28 Aug 2006, Andreas Jung wrote:
--On 28. August 2006 07:41:03 -0700 Dennis Allison <allison@shasta.stanford.edu> wrote:
AJ --
You are, of course, correct. I wanted Gaute to take a look at the actual code and proceed from there. Docfinder is also a useful approach for learning about the system.
Gaute --
If you are a frequent reader of this list, you know that AJ's style is to encourage posters to 1) be complete and precise in the questions they post and 2) provide just enough infomration for the poster to discover the answer to his/her post himself. This is an excellent pedagogical strategy but sometimes is frustrating.
No, it's personal laziness to provide the food bite-size :-)
Andreas
--
For what its worth, thanks AJ and others for the time you put into replying queries daily. I find often I don't have to ask because if someone hasn't already asked it someone else will soon ask. Not to mention, but I will, some of your responses (all of you) leaves me saying " I didn''t know you could do that" or "so that's how its done". Thanks, Thomas On Monday 28 August 2006 10:47, Andreas Jung wrote:
--On 28. August 2006 07:41:03 -0700 Dennis Allison
<allison@shasta.stanford.edu> wrote:
AJ --
You are, of course, correct. I wanted Gaute to take a look at the actual code and proceed from there. Docfinder is also a useful approach for learning about the system.
Gaute --
If you are a frequent reader of this list, you know that AJ's style is to encourage posters to 1) be complete and precise in the questions they post and 2) provide just enough infomration for the poster to discover the answer to his/her post himself. This is an excellent pedagogical strategy but sometimes is frustrating.
No, it's personal laziness to provide the food bite-size :-)
Andreas
-- ==================================================================== Thomas McMillan Grant Bennett Appalachian State University Computer Consultant III P O Box 32026 University Library Boone, North Carolina 28608 (828) 262 6587 An important measure of effort in coding is the frequency with which you write something that doesn't actually match your mental representation of the problem, and have to backtrack on realizing that what you just typed won't actually tell the language to do what you're thinking. -Eric Raymond Library Systems Help Desk: http://linux.library.appstate.edu/help ====================================================================
participants (9)
-
Andreas Jung -
Chris Withers -
Dennis Allison -
Gaute Amundsen -
Jens Vagelpohl -
Lennart Regebro -
Philipp von Weitershausen -
Thomas Bennett -
Tres Seaver