[storm] referenceset and lazy attributes

Bernd Dorn bernd.dorn at lovelysystems.com
Mon Sep 3 14:42:02 BST 2007



On 03.09.2007, at 15:32, Gustavo Niemeyer wrote:

>
>> I think a attribute-group implementation would be the best where  
>> we can
>> define which attributes are selected together. So in the example  
>> below
>> url and title would be fetched together.
>>
>> class A(object):
>>
>>     url = Unicode(group='smalltexts')
>>     title = Unicode(group='smalltexts')
>>     toc = Unicode(group='hugetexgts')
>
> One issue with that is that if you load 'toc', it wouldn't retrieve  
> 'url'
> and 'title', which are most probably wanted.  I wonder if we should  
> just
> stick with a simpler implementation.  E.g.:
>
>   class A(object):
>       url = Unicode()
>       title = Unicode()
>       toc = Unicode(lazy=False)
>       data = Unicode(lazy=False)
>
> Can you imagine a use case where this wouldn't be enough?
>
> Also, I wonder if 'toc' and 'data' should be loaded together, or if  
> they
> should be fetched individually on demand.

this question is exactly the use-case :-)

i can define for my application by grouping which attributes should  
be loaded together, if no group is defined it should be loaded with  
the initial getter (e.g. the primary keys)

so for example if i have an overview of objects in a web-page, and  
for the selected item i have a detail view on the same page it only  
fetches the title and url for the overview items and the 'toc' for  
the selected one. another example attribute in the 'hugetexts' gruop  
would be "abstract"


>
> -- 
> Gustavo Niemeyer
> http://niemeyer.net




More information about the storm mailing list