Hi All,

       I having some problems with having the event listen fire when I'm 
setting the attributes via a query.

Base = declarative_base()
lisDb = create_engine(Schema.lisDbstring())
Base.metadata = MetaData(bind=lisDb, schema=Schema.lisSchema())
lisSession = sessionmaker(lisDb)

easternTz = timezone('US/Eastern')

def eastern(lis_date):
    return easternTz.localize(lis_date)

def convert_timezone_aware(target, value, oldvalue, initiator):
    print "Got here"
    return eastern(value)

event.listen(BdsMeasure.mod_sysdat, 'set', convert_timezone_aware, retval = 
True)

# Below doesn't work
b = lisSession().query(BdsMeasure).filter(BdsMeasure.congress == '113', 
BdsMeasure.bill_number == 'HC00001').first()  
print b.mod_sysdat

setattr(b, 'mod_sysdat', datetime.now())    # This however does
print b.mod_sysdat

Can somebody shed some light on why the first setting of mod_sysdat is not 
working (see above) and how to fix it. I'm running 0.7 due to legacy code 
that we have not changed yet.

Thanks,
'Tino

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to