[Zope] Copying objects in ZODB programmatically

Dieter Maurer dieter@handshake.de
Sun, 14 Apr 2002 23:58:01 +0200


--iW+ZjGLbOM
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit

Noel Duffy writes:
 > >   *  create a request object with authentication information,
 > >      perform a "traverse" on this object (this will set the
 > >      user) and then call "manage_pasteObjects" on the traverse to
 > >      object.
 > >
 > 
 > Thanks for the quick reply.
 > 
 > Do you have an example of how one would do this, as I cannot quite
 > picture in my head how this should be approached?
Attached...

You would use it in the form:

    from request import getAuthRequest

    R=getAuthRequest() # your authenticated request object (sure, you modified USER and PASSWORD!)

    o= R.traverse(URL) # the (site relative) URL of the object you want to reach

    # whatever you want to do with "o"


Dieter

--iW+ZjGLbOM
Content-Type: application/x-python
Content-Description: Module to create a request/authenticated request for traversal
Content-Transfer-Encoding: base64

aW1wb3J0IG9zLCBzeXMKc3lzLnBhdGguYXBwZW5kKCdsaWIvcHl0aG9uJykKZnJvbSBaUHVi
bGlzaGVyLlJlcXVlc3QgaW1wb3J0ICBSZXF1ZXN0CmZyb20gWlB1Ymxpc2hlci5SZXNwb25z
ZSBpbXBvcnQgIFJlc3BvbnNlCmZyb20gWlB1Ymxpc2hlci5QdWJsaXNoIGltcG9ydCBnZXRf
bW9kdWxlX2luZm8KZnJvbSBiYXNlNjQgaW1wb3J0IGVuY29kZXN0cmluZwoKZT1vcy5lbnZp
cm9uCmVbJ1NFUlZFUl9OQU1FJ109ICdsb2NhbGhvc3QnOyBlWydTRVJWRVJfUE9SVCddPSAn
ODA4MCcKZVsnU0NSSVBUX05BTUUnXT0gJycKCihib2JvX2JlZm9yZSwgYm9ib19hZnRlciwg
b2JqZWN0LCByZWFsbSwgZGVidWdfbW9kZSwgZXJyX2hvb2ssCiAgICAgc2VjX21hbmFnZXIs
IGhhdmVfdHJhbnNhY3Rpb25zKT0gZ2V0X21vZHVsZV9pbmZvKCdab3BlJykKCmRlZiBnZXRS
ZXF1ZXN0KCk6CiAgcmVxdWVzdD0gUmVxdWVzdChzeXMuc3RkaW4sIGUsCgkJICAgUmVzcG9u
c2UoKSwKCQkgICApCiAgcmVxdWVzdFsnUEFSRU5UUyddPSBbb2JqZWN0XQogIHJldHVybiBy
ZXF1ZXN0CgpkZWYgZ2V0QXV0aFJlcXVlc3QoKToKICByPWdldFJlcXVlc3QoKQogIHIuX2F1
dGg9J2Jhc2ljICcgKyBlbmNvZGVzdHJpbmcoJ1VTRVI6UEFTU1dPUkQnKQogIHJldHVybiBy
Cg==
--iW+ZjGLbOM--