[Dev-flock] r281 - in huginmunin/trunk/web: . src/database/db

dan@thoughtandmemory.org dan at thoughtandmemory.org
Mon Oct 8 08:33:31 EDT 2007


 r296 at insignificant:  dan | 2007-10-08 06:33:04 -0400
 The single model file was getting way too long to handle (especially with comments everywhere.)  So I split it into several modules which hopefully make sense.
 
 The model API is pretty well documented, except for full-text search and Rating aggregation, but that stuff will come soon, and a framework is there in any case (just not the internals).  So hopefully the API from this point onward will only add functions, and not remove anything.
 
 Things to note (maybe?):
 1. I added convenience methods to everything, so Argument.objects.get(id=1) can be Argument.get(1) ('get' is list objects.get, except with a special case for ids); Argument.find is like objects.filter, again with a special case for single or multiple ids; Argument.add maps to Argument.make(blah).save().  They all mostly pass arguments through and only exist for convenience.
 2. When possible, (e.g., always, I think) use Argument.make() rather than Argument.objects.get_or_create(...), because Argument.make enforces rules on fields (like Rating).
 3. Don't need to specify user when saving objects.  Logging of username, IP, and time of save is handled automatically by the Log and Action classes with help from Django signals.
 4. When 'tam_middleware.LogVisits' is enabled, every visit is logged unless it matches 'exclude_pattern' (which currently excludes static pages, since 21 log entries per refresh is too many.)
 5. Many (most) attributes (where possible) are implemented with properties, so they should be accessible from Views without explicitly exporting them in a dict.
 6. I'm sure I missed stuff, so let me know.
 
 
 
 


Added:
   huginmunin/trunk/web/src/database/db/citation.py
   huginmunin/trunk/web/src/database/db/graph.py
   huginmunin/trunk/web/src/database/db/log.py
   huginmunin/trunk/web/src/database/db/rating.py
   huginmunin/trunk/web/src/database/db/search.py
   huginmunin/trunk/web/src/database/db/state.py
   huginmunin/trunk/web/src/database/db/tag.py
   huginmunin/trunk/web/src/database/db/user.py
   huginmunin/trunk/web/src/database/db/utils.py
Modified:
   huginmunin/trunk/web/
   huginmunin/trunk/web/src/database/db/models.py
   huginmunin/trunk/web/src/database/db/tests.py
   huginmunin/trunk/web/src/database/db/views.py



More information about the Dev-flock mailing list