Re: [sqlalchemy] Comparable properties

2010-07-08 Thread Chris Withers
Oliver Beattie wrote: @property def is_visible(self): return (self.enabled and not self.is_deleted) This can clearly be mapped quite easily to SQL expression `Klass.enabled == True Klass.is_deleted == False` You could always add a class-level attribute that stored this...

RE: [sqlalchemy] Comparable properties

2010-07-08 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Chris Withers Sent: 08 July 2010 09:28 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Comparable properties Oliver Beattie wrote: @property def is_visible

Re: [sqlalchemy] Comparable properties

2010-07-08 Thread Chris Withers
King Simon-NFHD78 wrote: @hybrid def is_visible(self): return (self.enabled == True) (self.is_deleted == False) Yeah, having to write something that works as both plain python and a sql layer construct seems a little brittle. I wonder if a decorator could be knocked up which would

[sqlalchemy] Comparable properties

2010-07-07 Thread Oliver Beattie
Hi, I am just wondering if it is possible to allow a declarative object to have some of its properties comparable as if they were ClauseElements. I know I'm not explaining myself terrifically well here, but consider the following property: @property def is_visible(self): return