Is it possible to use the Zope API to export a folder outside of zope, eg, either by using some combination of ZODB.ExportImport or OFS.ObjectManager? If not, can this be done with the XML-RPC patch that incorporates authorization headers? I want to set up a cron process that exports a folder to the local filesystem? Perhaps this can also better done within zope? Thanks, John hunter
On Mon, May 13, 2002 at 06:25:52PM -0500, John Hunter wrote:
I want to set up a cron process that exports a folder to the local filesystem? Perhaps this can also better done within zope?
look up the zcron product, you could have it do the export. Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
Forgive me if this is a stupid question but I'm still finding Zope's numerous namespaces confusing. I want to have a DTML method that has this in it: <dtml-let var1="'avalue'"> <dtml-var myscript> </dtml-let> And a python script call myscript that does something like: print mysterious_voodoo.getitem('var1') The right text for mysterious_voodoo eludes me. How do I access dtml-let set variables from a python script context? Is it possible? Passing the argument as a named keyword is something I want to avoid as there is a security issue with allowing users to type in URLs like http://blah/myscript?var1=evil_hacker_string As far as I can tell, there isn't a way the python script can tell if it was called directly via a URL or via the enclosing document. So I'd like to make sure it pulls its parameters from the DTML namespace stack.
"Charlie" == Charlie Reiman <creiman@kefta.com> writes:
Charlie> I want to have a DTML method that has this in it: Charlie> <dtml-let var1="'avalue'"> <dtml-var myscript> Charlie> </dtml-let> Charlie> And a python script call myscript that does something Charlie> like: Charlie> print mysterious_voodoo.getitem('var1') Charlie> The right text for mysterious_voodoo eludes me. How do I Charlie> access dtml-let set variables from a python script Charlie> context? Is it possible? There are two kinds of voodoo that will work for you here. The easiest is simply to pass the argument to the python script as a parameter. If you add var1 to the 'Parameter List' under the 'Edit' tab of the python script, then you can do <dtml-var expr="myscript(var1=var1)"> Alternatively, you can set the REQUEST header <dtml-call expr="REQUEST.set('var1', var1)"> and then in python REQUEST = container.REQUEST RESPONSE = REQUEST.RESPONSE var1 = REQUEST.get('var1') You said you were concerned about security: both of these approaches are less transparent to the user than passing them by the CGI myscript?var1=someval, but determined or savvy users can still read/edit the REQUEST headers, so don't be lulled into a false sense of security. Cheers, John Hunter
[Charlie Reiman]
I want to have a DTML method that has this in it:
<dtml-let var1="'avalue'"> <dtml-var myscript> </dtml-let>
And a python script call myscript that does something like:
print mysterious_voodoo.getitem('var1')
The right text for mysterious_voodoo eludes me. How do I access dtml-let
set
variables from a python script context? Is it possible?
Passing the argument as a named keyword is something I want to avoid as there is a security issue with allowing users to type in URLs like
You can still use named keywords and positional parameters, just don't use them right from the URL query string. Construct and test them yourself - as you seem to be doing anyway - then you can use them safely. Conversely, if var1 comes directly from the URL query string, it could do damage no matter how you transfer it to a script. Cheers, Tom P
"Paul" == Paul Winkler <pw_lists@slinkp.com> writes:
Paul> look up the zcron product, you could have it do the export. Thanks for the tip -- no matches for zcron on zope.org or sourceforge. On google, I tuned up a couple of hits where people referred to it on discussion lists, but no links to the code. I did see a ZScheduler on zope.org, but with a last release date of 2000/07/02, I was concerned that it may no longer be actively developed or maintained. I have been working on using the traditional wget/lynx approach to remote management, ie, wget http://user:pass@host:8080/path/to/folder/manage_exportObject which works fine for saving the file to the server. Is there some parameter I can pass to get the file exported to the local file system? Thanks, John Hunter
"John" == John Hunter <jdhunter@ace.bsd.uchicago.edu> writes:
John> Is there some parameter I can pass to get the file exported John> to the local file system? Just ran my sniffer to find the answer: wget -O Calendar.zexp 'http://user:pass@host:8080/some/path/Calendar/manage_exportObject?download%3...'
I have just finished a python script that solve the problem of exporting a remote zope folder to the local filesystem. The script takes a number of command line arguments to specify the remote server/folder/port and the local output dir. You can call this script from cron if you trust hiding your password in the /etc/cron.daily root folder. Otherwise, you can supply it to a getpass call Hope someone else finds it useful... ---- begin zope_export.p ---- #!/usr/local/bin/python # Command line args: # -d optional -- debug mode. If supplied, then just print the wget command # -s SERVER optional -- default 'localhost' # -f FOLDER required -- remote folder to backup # -o LOCALDIR optional -- local output directory, default '.' # -p PORT optional -- default 8080 # -u USER:PASS optional -- default prompt; username and password in format 'user:pass' # # Example usage: # ./zope_export.py -f 'SRP2002/Calendar' -s myhost.com -o /backup/ import os, time, sys, getopt, getpass optlist, args = getopt.getopt(sys.argv[1:], 'df:o:p:u:s:') # opts is a map from opts to default values. You can overrise the # default values, with, for example, myscript.py -s myhost.com. The # options with default value None must be supplied at the command line # or an error will be generated. opts = {} opts['d'] = 0 # debug mode opts['s'] = 'localhost' # remote zope server opts['f'] = None # remote folder to backup opts['o'] = '.' # output directory opts['p'] = 8080 # zope port opts['u'] = 0 # username:passwd for (opt, val) in optlist: #for binary opts, convert to 1 if val == '': val = 1 opts[opt[1]] = val for (key, val) in opts.items(): if val==None: print 'Error: You must supply the -%s option' % key sys.exit() if opts['u']==0: print 'Supply a username and password for %s in format user:pass' % opts['s'] opts['u'] = getpass.getpass('User:Pass ') folder = opts['f'] server = opts['s'] port = opts['p'] userpass = opts['u'] outDir = opts['o'] debug = opts['d'] script = 'manage_exportObject' cgi = """download%3Aint=1&submit=Export""" ymd = time.strftime('%Y-%m-%d', time.gmtime()) outFile = '%s/%s.%s.zexp' % ( outDir, folder.replace('/', '.'), ymd ) url = 'http://%s@%s:%d/%s/%s' % \ ( userpass, server, port, folder, script) if len(cgi)>0: url = url + '?' + cgi command = 'wget -q -O %s %s' % ( outFile, url) if debug: print command else: os.popen(command) ---- end zope_export.p ---- Here is an example file from /etc/cron.daily which calls this script. If you hardcode your user:pass, make sure you make the file 'chmod 600' --- begin /etc/cron.daily/zope_course_export --- #!/bin/sh # Export the course folder to /backup/ /usr/local/bin/python2.1 /usr/local/bin/zope_export.py -u myuser:mypass -o /backup -f SRP2002 -s myhost.com --- end /etc/cron.daily/zope_course_export ---
On Tue, May 14, 2002 at 09:45:51AM -0500, John Hunter wrote:
"Paul" == Paul Winkler <pw_lists@slinkp.com> writes:
Paul> look up the zcron product, you could have it do the export.
Thanks for the tip -- no matches for zcron on zope.org or sourceforge. On google, I tuned up a couple of hits where people referred to it on discussion lists, but no links to the code.
Oops. Got the name wrong. It's xron. -- Paul Winkler home: http://www.slinkp.com "Muppet Labs, where the future is made - today!"
participants (4)
-
Charlie Reiman -
John Hunter -
Paul Winkler -
Thomas B. Passin