[orm-devel] Re: Error in datasource.py ?

Diedrich Vorberg diedrich@tux4web.de
Thu, 21 Nov 2002 23:43:24 +0100


Hi Mike,

>Line 382 in datasource.py appears to be missing a parameter. Somewhere, I 
>can't remember where I stumbled across this, it appeared to me that "self" 
>needed to be the *second* parameter there. Perhaps it will jump out at you.
>
>With that line changed as follows:
>v.append("%s=%s" % (columnName, typ.format(value, self)))
>
>Works... but I'm not 100% sure the .format() method is actually expecting 
>those two parameters.

yes, this is correct, an error of mine. Thanks!

The datatype.format method takes a datasource as a second argument so 
it can check if the datasource provides any format function for that 
specific datatype.

There's a default format() function for any kind of SQL literal (for 
most Python's str() function does the trick) but if some backend 
needs a special format, it can provide an appropriate format 
function. 

Diedrich

-- 
           _..._                            Diedrich Vorberg
         .'     '.
        /  _   _  \                         http://www.tux4web.de
        | (o)_(o) |                         info@tux4web.de
         \(     ) /            .---.
         //'._.'\ \           /     \       Internet Dienstleistungen
        //   .   \ \          \.@-@./       und 'Consulting'.
       ||   .     \ \         /`\_/`\
       |\   :     / |        //  _  \\      Linux Rules!
       \ `) '   (`  /_      | \     )|_
     _)``".____,.'"` (_    /`\_`>  <_/ \
     )     )'--'(     (    \__/'---'\__/
      '---`      `---`