Hi Oleg,

yes, this sounds exactly like what i need.

I inserted it, but it doesn´t work - i´m really sorry but can you help me out?

class Reisen(SQLObject):
    class sqlmeta:
    REISENR        = StringCol(length=20, alternateID=True, dbName="REISENR") #CHAR(20)   
    def select(self, **kw):
        sresult = SQLObject.select(self, **kw)
        return sresult.filter(NOT(LIKE( Reisen.q.REISENR, "BUS%")))

i get an error: "TypeError: unbound method select() must be called with Reisen instance as first argument"

thank you!


On Jan 17, 2008 4:16 PM, Oleg Broytmann <phd@phd.pp.ru> wrote:
On Thu, Jan 17, 2008 at 04:10:17PM +0100, Frank Wagner wrote:
> I would like to put a certain where-condition to a class of mine, so that to
> every select against that table my condition is added. I think this must be
> put within the class-definition.

  I think you you'd want to override .select(). Something like this:

class MyTable(SQLObject):
  def select(self, **kw):
     sresult = SQLObject.select (self, **kw)
     return sresult.filter(additional_clause)

  Please note that .select() returns an instance of SelectResults class
which you further filter with its .filter() method, and then return the new
instance to the caller.

    Oleg Broytmann            http://phd.pp.ru/            phd@phd.pp.ru
          Programmers don't die, they just GOSUB without RETURN.

This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
sqlobject-discuss mailing list