Maniac wrote:
>
> Robert Wittams wrote:
>
>> reporter.articles
>> reporter.articles.filter(headline__startswith='This').order_by('headline')
>>
>> reporter.articles.add(headline="John's second story",
>> pub_date=datetime(2005, 7, 29))
>>
>>
>> ?
>>
>>
> The only objection I can think of is that such property notation implies
> the notion that 'articles' is a stable list and thus 1) can be accessed
> fast 2) can't change unexpectedly. While function notation
> 'get_article_list()' clearly shows that it can take some time and the
> result can be different on each call.
>
Good points, but I don't think those objections hold much water in the
context of an ORM:
* IMO, the metric for whether something should look like a property or a
method is not how much computation it does, but whether it has
side-effects on meaningful state ( ie not logging or cacheing). This is
probably personal taste...
* The idea that a variable is "stable" from one call to the next is an
odd one in a concurrent environment without locking or transactions.
* The point of an ORM to make things easier - to abstract *away* from
the nitty gritty of messing with databases - not to rub it in your face
all the time.
* If you are using Django and have set up your database, you would have
to be somewhat simple not to work out that this is going to hit the
database at least some of the time ;-)