[Twisted-Python] Store simple value in web session
benoit.fleury at gmail.com
Wed Sep 5 21:32:29 EDT 2012
Thank you for the explanation.
On Wed, Sep 5, 2012 at 8:58 PM, Glyph <glyph at twistedmatrix.com> wrote:
> On Sep 5, 2012, at 5:32 PM, Benoît Fleury <benoit.fleury at gmail.com> wrote:
>> 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.)
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python