OK, take a look at an example we have in examples/derived_attributes/ 
attributes.py.  This is doing a "dual use" descriptor which works at  
the class level and instance level.  Its more complicated but with  
some tweaking can probably work like the example you're giving.



On Oct 13, 2008, at 4:14 PM, g00fy wrote:

>
> I did:
>
>    class AreaProxy(object):
>        def __init__(self,parent):
>            self.parent=parent
>        def __getattr__(self, key):
>            return self.parent.area_total
>            return getattr(self.parent, "area_" + key)
>    @property
>    def area(self):
>        return Warehouse.AreaProxy(self)
>
> but when filtering :
>
> filter(Warehouse.area.total>=100)
> i get
> AttributeError: 'property' object has no attribute 'total'
>
> On 13 Paź, 22:00, g00fy <[EMAIL PROTECTED]> wrote:
>> I am talking about both.
>>
>> I said it right,
>> It wasn't working becouse it returned a string column name, and  
>> should
>> return a value on instance.
>> And i want to be able to filter by this property also.
>>
>> On 13 Paź, 21:56, Michael Bayer <[EMAIL PROTECTED]> wrote:
>>
>>> On Oct 13, 2008, at 3:40 PM, g00fy wrote:
>>
>>>> I want to:
>>>> Warehouse.area.total
>>>> to return
>>>> Warehouse.area_total
>>
>>>> and so on :
>>>> Warehouse.area.storage
>>>> returns:
>>>> Warehouse.area_storage
>>
>>> then why did you say:
>>
>>>> And this isn't working becouse:
>>>> Warehouse.area.total
>>>> returns
>>>> .area_total
>>
>>> are you talking about class-level SQL predicates, or instance-level
>>> attribute values ?   composite will give you the latter, the  
>>> recipe I
>>> gave will give you the former.    The recipe can be adjusted to
>>> produce both but its more complicated.
>>
>>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to