[sqlalchemy] adding validates() decorator after class creation

2013-01-04 Thread lars van gemerden
Hi, I am trying to use validates() to dynamically add validation to my sqla classes, but i cannot figure out how to do this. I have read python decorator docs and docs n validates, but something escapes me (or it is just not possible). A code snippet (this does not work): def

[sqlalchemy] Re: max() min() string lengths?

2013-01-04 Thread Jason
On Thursday, January 3, 2013 10:08:19 PM UTC-5, ocicat wrote: Embarrassingly, I'm gotten lost in calling SQL functions in SQLAlchemy 0.7.1. I can boil the problem down to the following table structure: CREATE TABLE words ( id INTEGER NOT NULL, timestamp DATETIME NOT

Re: [sqlalchemy] How to handle 'sub-commits'?

2013-01-04 Thread Michael Bayer
On Jan 3, 2013, at 10:18 PM, Ken Lareau wrote: I recently (today) ran into an issue that has me perplexed as to how to resolve it, so I'm asking here to see if anyone can shed some insight. Hopefully I can ex- plain it clearly enough to make me not sound completely incompetent... I

Re: [sqlalchemy] Query about exception being raised on violating uniqueness constraint

2013-01-04 Thread Michael Bayer
Would need much more detail here including a full stack trace, what line you're referring to in _flush(), and preferably code which reproduces the error you're seeing. On Jan 4, 2013, at 1:55 AM, Gurjar, Unmesh wrote: Hi, I have installed SQLAlchemy 0.7.9 (backend – MySQL, Python 2.7). I

Re: [sqlalchemy] adding validates() decorator after class creation

2013-01-04 Thread Michael Bayer
@validates is a decorator that's typically associated with a class before it's mapped. It is essentially a mapper-time directive which is converted into an attribute event. If you're trying to associate these events with class attributes en-masse, and particularly that may already be mapped,

Re: [sqlalchemy] max() min() string lengths?

2013-01-04 Thread Simon King
On 4 Jan 2013, at 03:08, James Hartley jjhart...@gmail.com wrote: Embarrassingly, I'm gotten lost in calling SQL functions in SQLAlchemy 0.7.1. I can boil the problem down to the following table structure: CREATE TABLE words ( id INTEGER NOT NULL, timestamp DATETIME NOT

[sqlalchemy] Re: adding validates() decorator after class creation

2013-01-04 Thread lars van gemerden
Perfect (almost ;-), thanks a lot! for future reference, the attribute name (key) was needed in create_validator(cls) to access the correct validate method: @staticmethod def _create_validator(key, cls): def validate(target, value, oldvalue, initiator):