Here'a little py script for a plone page template...
I just want to translate the 'key' (organicnews) to a 'value' (Organics in the
News), for presentation purposes. (the key, of course, is in the URL request)
db = request.db
if db=="organicnews":
print "%s" % html_quote('Organics in the News')
elif db=="ovnews":
print "%s" % html_quote('Our Stuff in the News')
elif db=="pressreleases":
print "%s" % html_quote('Press Releases')
else:
print "Unknown News Database!",
print "%s" % db
return printed
Use a dictionary:
responses = {"organicnews": "Organics in the News'", "ovnews" : "'Our Stuff in the News'", "pressreleases" : "'Press Releases'"}
print html_quote(responses.get(db, "Unknown News Database! " + db))
BTW there is no benefit to print '%s' % blahblah. print blahblah does the same thing.
[snip]
I know there's a proper way to do this with a tuple, or something :)
For the three values, it's not a problem, but if I want to scale up to many, I
imagine the dictionary is the way to go...
mailto:[EMAIL PROTECTED]
510 558 3275 home
720 938 2625 cell
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor