[Zope] Re: Python Script HowTo (WAS: How do I get the value of an
object with python?)
Evan Simpson
evan at 4-am.com
Mon Aug 25 15:34:00 EDT 2003
Bill Hewitt wrote:
> * Via Python, collect all instances of StyleSheet that exist in
> StyleBook (via unique object ID)
Since your StyleSheet is a Folder, you should be able to use 'objectIds'
and company with a meta-type argument. I'm not sure what your
parenthesized bit means.
> * Via Python, look at the title and styletype properties of each
> StyleSheet instance and compare them against my query arguments
The 'title' should be accessible as a simple attribute. I presume that
'styletype' is defined on a ZClass propertsheet, so you may need to
write something like "ss.propertysheets.get('mysheet').styletype"
> * If I find a match, return all the Property values(potentially 47+) of
> the particular StyleSheet instance (that are not empty strings) in a CSS
> Format.
Hmm. Here an utterly untested code snippet that may help, intended to
be the body of a Script in StyleBook
##parameters=a_title, a_type
props = []
for ss in container.objectValues(['StyleSheet']):
if (ss.title == a_title and
ss.propertysheets['mysheet'].styletype == a_type):
for p in ss.propertysheets.get('mysheet').propertyItems():
props.append('%s: %s' % p)
return '; '.join(props)
Cheers,
Evan @ 4-am
More information about the Zope
mailing list