On Wed, 2008-03-05 at 02:40 -0800, Thierry wrote:
> Basically the effect of implementing a singleton in php.
> Not sharing anything between requests.
> But sharing during on request.
> 
> For instance you would have one javascript object, which you get
> through getInstance()
> It always returns the same object with a list of js files.
> Then in the view or wherever you simply append or remove from the
> list.
> 
> Problem with my singleton approach is that it appends across requests.
> So for every request I double the ammount of js it loads :)

That's the way Python works: a module-level global (which is what you're
creating) will exist for the life of the module, which is longer than
one request.

A more robust design pattern is to create this object that only has a
request-based lifecycle inside the first view that needs it and pass it
around as a parameter to the other functions that need it.

Malcolm

-- 
Depression is merely anger without enthusiasm. 
http://www.pointy-stick.com/blog/


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

Reply via email to