My randomImage Python script is as follows (where 'directory' is the parameter being passed to the script):
import string import random
directory_context = string.replace("/", ".", directory) return directory + "/" + random.choice(context.directory_context.objectValues('Image'))
Passing in a string makes this trickier, as I guess you've already realized. What you're doing in context.directory_context.objectValues('Image') is trying to call a string (directory_context) like an ObjectManager. Not going to work. Python lets you get away with a lot, but not that much. As suggested previously, you can turn the string into an object by restrictedTraverse(). In similar situations, involving non-traversable attributes, you might use Python's getattr() built-in. --jcc