>> What is proper way to use singletons with Nagare?
>> The most common way (with class variables) leads to sharing the singletons 
>> between different sessions.
>> How to make session-specific singletons with Nagare?
> 
> I'm not sure to understand what's your needs.
> 
> With Nagare, a session contains all the objects/components of your 
> application.
> So every attribute of any objects is already a << session-specific >> data.
> 
> For example, if the '__init__()' method of your root component has a
> 'self.my_service = MyService()' statement, then 'self.my_service' is bound to
> the user session.
> 
> Do you have a more concrete use-case?


I want to make a singleton -- a class of objects, where all objects shares 
their attributes, like a global variable.
The typical way to achieve this -- overload __new__() method to always return 
an one instance, stored in class attribute.
It's works in Nagare, but the instance will be shared between all sessions, 
which is bad for me, because I want to store access rights and authentication 
information in this object.
Pierre Meyer recommended me (thanks, Pierre!) to use `stateless` function for 
the singleton instance, may be it will help.

Pavel.


-- 
You received this message because you are subscribed to the Google Groups 
"Nagare users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nagare-users+unsubscr...@googlegroups.com.
To post to this group, send email to nagare-users@googlegroups.com.
Visit this group at http://groups.google.com/group/nagare-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to