On Jan 12, 2009, at 7:53 AM, Peter Seckler wrote:

> how do I give the user of the Dabo application the possibility to  
> explicitly set a database field to NULL? Say, there is a table:
>
> CREATE TABLE items (
> id serial primary key,
> item text,
> description text,
> size integer)
>
> and three dTextBox widgets associated with those fields.
>
> The table contains the following record (3, "Some Item", "Some  
> Description", 15),
>
> how can the user set items.size and items.description to NULL?  
> Leaving the TextBox blank doesn't work.  Is there a special key  
> sequence or something like that? Or do I have to code this myself  
> for every field like
>
> if fieldValue=="" then fieldValue=None  ?

        That's one that I haven't thought about. UIs typically don't have a  
way to enter null values without using separate controls. If you  
wanted to do this all with a textbox, you could do something like  
this: establish a string that will represent null (say, 'null' or  
'None', depending on your preference), and then in the bizobj for that  
table, override setFieldVal() like this:

def setFieldVal(self, fld, val, row=None):
        if fld in ("item", "description"):
                if val == "null":
                        # This is the string indicating null values
                        val = None
        super(ThisBizobjClass, self).setFieldVal(fld, val, row=row)



-- Ed Leafe





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to