On Sep 5, 2012, at 5:32 PM, Benoît Fleury <[email protected]> wrote:

> Hi,
> 
> I would like to store a simple (immutable) value in a web session.
> 
> Here are the options I see so far:
> - use the component architecture (seems a bit overkill...)
> - subclass Session to hold the value I want to store
> - patch Session to behave like a dictionary (didn't look at the code,
> not sure if it makes sense...)
> 
> I'm also curious about the advantages of this component architecture
> for the session object instead of a simple dictionary?

The component architecture just uses interfaces as keys so that it is 
unambiguous which piece of code owns them, and what properties they are 
supposed to provide.  This is so that multiple bits of twisted.web 
infrastructure can cooperatively populate the request with state without 
interfering with each other.

I would suggest that it's not "overkill" - it sounds like exactly what you 
want.  (I suspect that you feel it's overkill because you have bad experiences 
with some other hideously bloated thing that was also called "component 
architecture", but I assure you, it's really just a dictionary.)

-glyph
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to