[sqlalchemy] Re: hybrid_property and filter_by() or filter()

2012-05-02 Thread cpldave
OK, to answer my own query this works fine: -- class User(object): username_enc = Column(String(128)) @hybrid_attribute def username(self): return decrypt_string(self.username_enc) @username.setter def

[sqlalchemy] Re: hybrid_property and filter_by() or filter()

2012-05-02 Thread cpldave
Just found this useful page with an example: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SymmetricEncryption Not 100% sure what is going on with a class being defined within the Model class itself, but I'll have a play around and see where I can get to with that. Thanks. On May 2, 5:33 pm,

[sqlalchemy] hybrid_property and filter_by() or filter()

2012-05-02 Thread cpldave
Hi All, I am trying to write a model that will encrypt all data at the database level, but can be accessed easily through normal attributes. I stumbled across the hybrid_property feature and it works fine, as long as I don't try and filter() or filter_by() my hybrid_property. The thing is it'd be

Re: [sqlalchemy] DeletedAtQuery

2012-05-02 Thread Andrei Chirila
Hi Michael, Thank you for the quick answer. I'll switch to subqueryload. Andrei On Wed, May 2, 2012 at 4:55 PM, Michael Bayer wrote: > this is not really a built-in SQLAlchemy feature so the quick thing I can > advise is to use subqueryload() instead, which makes use of Query to get at > the re

Re: [sqlalchemy] DeletedAtQuery

2012-05-02 Thread Michael Bayer
this is not really a built-in SQLAlchemy feature so the quick thing I can advise is to use subqueryload() instead, which makes use of Query to get at the related "pets" collection, rather than appending to the query directly as joinedload does. Your other option would be to use a custom primary

[sqlalchemy] DeletedAtQuery

2012-05-02 Thread Andrei Chirila
Hello, A couple of months ago I was asking on the list about a query class that could support a "deleted_at" attribute for the models, such as when a object it's deleted, the statement it's transformed into an update with the field set to a certain date. Just now I noticed that my class is not fri

Re: [sqlalchemy] How to properly use a property for self._value or self.parent.value

2012-05-02 Thread Michael Bayer
On May 2, 2012, at 8:34 AM, Moritz Schlarb wrote: > Thank you, Michael! > > But could I achieve it somehow using hybrid properties and a case statement? > > I tried something like: > > @hybrid_property > def time(self): > return self._time or self.event.time > > @time.

Re: [sqlalchemy] How to properly use a property for self._value or self.parent.value

2012-05-02 Thread Moritz Schlarb
Thank you, Michael! But could I achieve it somehow using hybrid properties and a case statement? I tried something like: @hybrid_property def time(self): return self._time or self.event.time @time.expression def time(cls): return case([(cls._time != None, cls

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2012-05-02 Thread David Bowser
Nope, just use the one inside the scope, TagMixin.TagClass, like so for your example: session.add(User.TagClass(tagged=doc1,name='foo')) On May 2, 2012, at 5:07 AM, Ciaran Farrell wrote: > But how would you actually add a tag? For example, say, using the example you > provided below, I had

Re: [sqlalchemy] Multi-table (polymorphic?) row-specific relations

2012-05-02 Thread Ciaran Farrell
But how would you actually add a tag? For example, say, using the example you provided below, I had a table called Document, which has is 'taggable'. If I create a Document object (doc1), I can see doc1.tags, which is a list. However, how do I actually _add_ a tag to doc1? I have a TagMixin obje