Ejemplo n.º 1
0
    def set_value( me, context, fieldname, value, do_get_check =True, next_adr =None, **kargs):
        #if fieldname not in me.field_map: return
        if me._DBG_set_value: print '\n set %s ?= %r' % (fieldname, value)
        model = me.model
        if do_get_check:
            try:
                oldvalue = get_attrib( model, fieldname)
            except AttributeError:
                e = me.ERR_not_in_model % fieldname
                print e
                return
#        if next_adr: print 'focusto', next_adr
        me.focus = next_adr or fieldname        #before set - if exception, focus goes to error field
        set_attrib( model, fieldname, value)
        if me._DBG_set_value: print ' --> %s == %r' % (fieldname, get_attrib( model, fieldname))
Ejemplo n.º 2
0
        def test_4_structitems( me):
            class B( StaticStruct):
                i = Number()
                n = Text()

            class A( StaticStruct):
                m = Sequence( item_type=B, )

            a = A()
            a.m._incr()
            #print a.m
            #print len(a.m), a.m, id(a.m), type(a.m), id(a.m)
            v = 4
            a.m[0].i = v
            me.assertEquals( a.m[0].i, v)
            a.m[0].n = 'ino'
            v = 14
            set_attrib( a, 'm.items.0.i', v)
            me.assertEquals( a.m[0].i, v)