PEAK: Python Enterprise Application Kit The road less traveled is the way to the top.

   

PEAK Considered Useful

By Phillip J. Eby
Saturday, November 09, 2002

"This is something I could almost use!"
-- Ty Sarna, commenting on PEAK this week

Yep, that's right, PEAK has reached a stage in its development where we can say "PEAK Considered Useful".  That doesn't mean it's time to rush right out and start building huge apps with it, but Ty has already started using it for short DB-access scripts and as a configuration tool for some existing apps that needed to have configuration support added.  We've also been using a few things from the peak.util package in production for a couple of months now.

What's new and exciting is that the recent addition of configuration files has suddenly made all sorts of things in PEAK much more "scalable", in the sense that it has made it much easier to add all sorts of new address types for database connections and the like.  It's also made it easier to create and access all sorts of specialized properties.  For example, our database drivers can use configuration properties to get things like type converters, BLOB size limits, etc., from their context.

For our "real world" use, Ty's already created a couple of naming contexts that look up information from various enterprise configuration datasets that we have at our day jobs, and written configuration files that set those contexts as the default naming context.  Thus, when one of his scripts says something like:

from peak.api import *
conn = naming.lookup("someDB")

He ends up with conn being a ManagedConnection subclass of the right type for the database, preconfigured with all the login data. He can proceed immediately to perform queries on it...

row = ~conn("select * from some_table where the_key=?", (aKey,))

print row.foo, row.bar, row.baz

Of course, the connection isn't really opened until he actually queries it, so he can always do something like this instead:

class MyApp(binding.Component):

    myDB = binding.bindTo("someDB")

    def showRow(self, aKey):
        row = ~ self.myDB("select * from some_table where the_key=?", (aKey,))
        print row.foo, row.bar, row.baz

if __name__=='__main__':
    import sys
    MyApp().showRow(sys.argv[1])

Now his script can be imported as a module, and MyApp subclassed... or used as part of a larger component. That larger component could supply a different context or meaning for "someDB" than it has when used in this context. Or it might supply different settings for properties such as type converters that might change the type of object "row.foo" returns. Or, he could have called MyApp(myDB=naming.lookup("anotherDB")) and overridden the default. The possibilities are darn near endless.

The other big thing that's exciting about PEAK's progress is that all of the architectural pieces are finally falling into place; soon I'll have taken out everything that can be taken out, cleaned up everything cleanable, and have a minimalist system where all the pieces are necessary, distinct, and functional. So there's now a very short to-do list for the 0.5 release. Depending on how long it takes to update the reference docs, we might have an 0.5 Alpha 1 release by the end of the month, and depending on how long it takes to finish the tutorial, maybe an 0.5 beta release by year-end.

Now if you'll excuse me, I have to get back to work on it... ;-)


 

documentation

community

resources

download