Bugfix in the search engine, implemented float fields in the advanced search, execute batchjobs as Zope admin.
This commit is contained in:
parent
d192496c88
commit
bdc7baf25a
5 changed files with 61 additions and 36 deletions
|
@ -247,10 +247,10 @@ class ZodbBackupScript:
|
|||
# Check command format
|
||||
if options.command:
|
||||
parts = options.command.split(':')
|
||||
if len(parts) not in (3,4):
|
||||
if len(parts) not in (4,5):
|
||||
raise BackupError('Command format must be ' \
|
||||
'<PloneInstancePath>:<ApplicationName>:<ToolMethodName>' \
|
||||
'[:<args>]')
|
||||
'<ZopeAdmin><PloneInstancePath>:<ApplicationName>:' \
|
||||
'<ToolMethodName>[:<args>]')
|
||||
|
||||
def run(self):
|
||||
optParser = OptionParser(usage=ZodbBackupScript.__doc__)
|
||||
|
@ -313,10 +313,11 @@ class ZodbBackupScript:
|
|||
type='string')
|
||||
optParser.add_option("-c", "--command", dest="command",
|
||||
help="Command to execute while Zope is running. It must have the " \
|
||||
"following format: <PloneInstancePath>:<ApplicationName>:" \
|
||||
"<ToolMethodName>[:<args>]. <PloneInstancePath> is the path, " \
|
||||
"within Zope, to the Plone Site object (if not at the root of " \
|
||||
"the Zope hierarchy, use '/' as folder separator); " \
|
||||
"following format: <ZopeAdmin>:<PloneInstancePath>:" \
|
||||
"<ApplicationName>:<ToolMethodName>[:<args>]. <ZopeAdmin> is the " \
|
||||
"user name of the Zope administrator; <PloneInstancePath> is the " \
|
||||
"path, within Zope, to the Plone Site object (if not at the " \
|
||||
"root of the Zope hierarchy, use '/' as folder separator); " \
|
||||
"<ApplicationName> is the name of the Appy application; " \
|
||||
"<ToolMethodName> is the name of the method to call on the tool " \
|
||||
"in this Appy application; (optional) <args> are the arguments " \
|
||||
|
|
25
bin/job.py
25
bin/job.py
|
@ -1,8 +1,9 @@
|
|||
'''job.py must be executed by a "zopectl run" command and, as single arg,
|
||||
must get a string with the following format:
|
||||
|
||||
<PloneInstancePath>:<ApplicationName>:<ToolMethodName>[:<args>].
|
||||
<ZopeAdmin><PloneInstancePath>:<ApplicationName>:<ToolMethodName>[:<args>].
|
||||
|
||||
<ZopeAdmin> is the userName of the Zope administrator for this instance.
|
||||
<PloneInstancePath> is the path, within Zope, to the Plone Site object (if
|
||||
not at the root of the Zope hierarchy, use '/' as
|
||||
folder separator);
|
||||
|
@ -16,7 +17,8 @@
|
|||
are supported). Several arguments must be separated by '*'.'''
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
import sys
|
||||
import sys, transaction
|
||||
|
||||
# Check that job.py is called with the right parameters.
|
||||
if len(sys.argv) != 2:
|
||||
print 'job.py was called with wrong args.'
|
||||
|
@ -24,20 +26,26 @@ if len(sys.argv) != 2:
|
|||
else:
|
||||
command = sys.argv[1]
|
||||
parts = command.split(':')
|
||||
if len(parts) not in (3,4):
|
||||
if len(parts) not in (4,5):
|
||||
print 'job.py was called with wrong args.'
|
||||
print __doc__
|
||||
else:
|
||||
# Unwrap parameters
|
||||
if len(parts) == 3:
|
||||
plonePath, appName, toolMethod = parts
|
||||
if len(parts) == 4:
|
||||
zopeUser, plonePath, appName, toolMethod = parts
|
||||
args = ()
|
||||
else:
|
||||
plonePath, appName, toolMethod, args = parts
|
||||
# Zope was initialized in a minimal way. Complete Zope and Plone
|
||||
# installation.
|
||||
zopeUser, plonePath, appName, toolMethod, args = parts
|
||||
# Zope was initialized in a minimal way. Complete Zope install.
|
||||
from Testing import makerequest
|
||||
app = makerequest.makerequest(app)
|
||||
# Log as Zope admin
|
||||
from AccessControl.SecurityManagement import newSecurityManager
|
||||
user = app.acl_users.getUserById(zopeUser)
|
||||
if not hasattr(user, 'aq_base'):
|
||||
user = user.__of__(uf)
|
||||
newSecurityManager(None, user)
|
||||
|
||||
# Get the Plone site
|
||||
ploneSite = app # Initialised with the Zope root object.
|
||||
for elem in plonePath.split('/'):
|
||||
|
@ -48,4 +56,5 @@ else:
|
|||
# Execute the method on the tool
|
||||
if args: args = args.split('*')
|
||||
exec 'tool.%s(*args)' % toolMethod
|
||||
transaction.commit()
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue