Gre7g Luterman <[EMAIL PROTECTED]> writes: > On 03 Dec 2002 23:17:54 -0600, Tim Legant > <[EMAIL PROTECTED]> wrote: > > > Here's the beginning of the problem, though. Because of namespaces, > > which are a wonderful and powerful organizational mechanism in a > > programming language, the above would actually be something like this: > > > > from TMDA import Message > > from TMDA import Action > > <snipped> > > Or we could manufacture a namespace to cater to the filter file.
Right. I was actually suggesting manufacturing three namespaces, for the sake of modularity. None of the three I suggested are currently present in the TMDA package. > This wouldn't have to be done if we are using the Python filter as > an intermediary format because who cares if it is wordy? Good point. > But if we wanted to encourage people to write Python filters, we could > do something like this very silly example: > > $ cat filter.py > def filter(): > if cond: do_something() > > $ cat try_filter.py > import filter > def do_something(): > print "Yay! We did something!" > cond = 1 > filter.do_something = do_something > filter.cond = cond > filter.filter() > > $ python try_filter.py > Yay! We did something! You'd have to set numerous things in the 'filter' namespace. I'm not sure of the mechanism. I had thought it was the __import__ statement, but after re-reading the docs, that won't really help us. It's a callback function that can be overridden to provide different behavior to the basic 'import' statement. In any case, we'd pass some function a dictionary, the "global" namespace for the filter, which would include all of Defaults.py as well as any other variables related to the message and our library. We would probably wrap that up in an 'include()' function that users could use to include subfilters, because otherwise it would be horrible code for them to have to write. Tim _________________________________________________ tmda-workers mailing list ([EMAIL PROTECTED]) http://tmda.net/lists/listinfo/tmda-workers
