[Zope-CMF] Workflow - Publish All Objects in Folder
Jo Meder
jo@meder.de
Wed, 3 Apr 2002 11:36:38 +0200
Am 03.04.2002, 10:14 Uhr
schrub Roel Van den Bergh <roel@planetinterior.com>:
> Unfortunately your solution didn't work
Sorry to hear that. Maybe there's something else missing. Here is the
complete script. It publishes everything inside the container it is
called from and recursively everything below that. Never failed me but
as usual there are certainly many opportunities for improving this
little snippet:
-----------------------------------------------------------------------------
def publishcontainer(container,path):
ov=map(lambda x:(x.id,x), container.objectValues())
ov.sort()
for (oid,obj) in ov:
if not (hasattr(obj,"isPortalContent") or obj.isPrincipiaFolderish):
continue
review_state=""
if hasattr(obj,"isPortalContent"):
print "ID: ",path+"/"+str(obj.id)
review_state=context.portal_workflow.getInfoFor(obj,'review_state','')
#print review_state
if review_state!="published" and hasattr(context,"portal_workflow"):
try:
context.portal_workflow.doActionFor(obj,'publish')
print "now published<br>"
except:
print "publishing",str(obj.id),"failed<br>"
elif review_state=="published":
print "is already published<br>"
if hasattr(obj,"objectValues"):
print publishcontainer(obj,path+"/"+str(obj.id))
return printed
print "This is the", script.meta_type, '"%s"' % script.getId(),
if script.title:
print "(%s)" % html_quote(script.title),
print "in", context.absolute_url()
print "<h2>Trying to publish all unpublished content</h2>"
print publishcontainer(context,context.absolute_url(relative=1))
return printed
---------------------------------------------------------------------------
Jo.
--
Internetmanufaktur Jo Meder ---------------------- Berlin, Germany
http://www.meder.de/ ------------------- fon: ++49-30-417 17 63 33
Kollwitzstr. 75 ------------------------ fax: ++49-30-417 17 63 45
10435 Berlin --------------------------- mob: ++49-170- 2 98 89 97
Public GnuPG-Key ---------- http://www.meder.de/keys/jo-pubkey.txt