Changes between Version 13 and Version 14 of DescriptorFields


Ignore:
Timestamp:
12/20/2005 11:51:33 AM (10 years ago)
Author:
rjwittams
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DescriptorFields

    v13 v14  
    1919     article.get_reporter()
    2020     article.reporter_id
    21    }}}
     21   }}} 
    2222
    2323   would change to:
     
    118118''When you finally open a ticket on this massive change ;) I'll add a comment that you should feel free to steal code from Dejavu, which has used descriptors successfully for two years now: http://projects.amor.org/dejavu/browser/trunk/units.py  -- Robert Brewer''
    119119
    120 The reason we avoided this in the initial design of Django is that we wanted it to be clear when an action would result in a database query being executed. This explicitness makes it easier to optimise your code - it's obvious when an action will result in an extra query, making it clearer when you should store results in a local variable for later use. -- Simon Willison
     120The reason we avoided this in the initial design of Django is that we wanted it to be clear when an action would result in a database query being executed. This explicitness makes it easier to optimise your code - it's obvious when an action will result in an extra query, making it clearer when you should store results in a local variable for later use. -- Simon Willison .
     121
     122I think the mailing list is better for discussions, but I don't think that you need to worry about the local variable thing. You can still save things in a local variable, exactly as before. The only change is that things will not actually be fetched until required. After that, they will be cached. -- Robert Wittams
     123
     124eg,
     125
     126{{{
     127simons = Person.objects(name_startswith="Simon")
     128
     129for simon in simons: <--- hits database
     130   pass
     131
     132for simon in simons: <--- uses cache
     133   pass
     134
     135}}}
Back to Top