On Dec 15, 2003, at 4:26 AM, Guenther Starnberger wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> hi,
>
> some time ago there was a thread on this mailinglist, about overiding
> the
> new() method in classes inherited from SQLObject.
> (http://thread.gmane.org/gmane.comp.python.sqlobject/906)
>
> according to a posting in this thread it is possible to call the
> 'original'
> SQLObject new() method by: 'SQLObject.new(cls, **kw)'.
>
> but somehow this doesn't work for me :/
>
> class Account(SQLObject):
> __name = StringCol(alternateID = True)
> __password = StringCol()
>
> __def new(cls, **kw):
> ____print "FOO"
> ____SQLObject.new(cls, **kw)
>
> __new = classmethod(new)
>
> calling Account.new just results in the following exception when
> SQLObject.new
> gets called:
>
> TypeError: new() takes exactly 1 non-keyword argument (2 given)
>
> i tried some variantions of calling SQLObject.new (e.g. without cls,
> ...) but
> they didn't work.
>
> any ideas how it is possible to call SQLObject.new?
Yes, it seems like classmethods are a little funny. I think I've
gotten it to work with super(MyClass).new(**kw)
--
Ian Bicking | ia...@co... | http://blog.ianbicking.org
|