[Zope] ZSQLMethodFile?

Peter Bengtsson mail@peterbe.com
Thu, 12 Jun 2003 00:13:50 +0100


> 
> I wrote a product for just this purpose: using ZSQLMethods in fs-based 
> products. Has some other neat features besides.
> 
> http://www.zope.org/Members/jccooper/extzsql
> 

I'm not convinced. The solution I currently have (if it works when I 
start using it) is great.

It looks something like this::

class MyProduct(ObjectManager, SQLClass):
     def helloworld(self, bar):
        return SelectWorldSQLStatement(foo=bar)

class SQLClass(Acquisition.Implicit):
     pass

for filename, params, statement in getFilesEndingWithDotsql():
     setattr(SQLClass, SQL(filename, 'No title', DBCONNECTION, params, 
statement))


The "only" problem is refreshing.
Not yet attempted this but it should be a good candidate::

I subclass SQL ("from Products.ZSQLMethods.SQL import SQL") and 
intercept the __call__ method to do something like this::

  if SQL_HARD_REFRESH_MODE:
     self.manage_edit(... open(filename).read() ...)

I bet there are going to implications that need serious python thinking, 
but that'll just be a challange.

What do you think about this?

Peter