I released webpy-mongodb-sessions<https://github.com/jab/webpy-mongodb-sessions/tree/v0.1> recently (originally authored by Steven Anderson) which provides a MongoDB-backed store for web.py sessions. Originally, when you assigned a value to a session attribute, the original version of the library put the value in a corresponding MongoDB document as-is. This restricts the types of values you can store in sessions to those you can put in MongoDB documents: strings, floats, bools, lists, dicts, None. Try to add a value of any other type and you'd get an error like bson.errors.InvalidDocument: Cannot encode object: ...
One of the modifications I made was to call web.session.Store.encode on the value before putting it in the document, allowing you to add any pickleable object to the session, which is how web.session.DiskStore and DBStore work for exactly this reason. The downside to this approach is the data stuffed in the session documents is totally opaque to the database. For instance, if you store an "npageviews" attribute on all your sessions, and you want to query the database against it, you can't because it's stuffed inside a pickled base64-encoded string. What is the correct design here? I suspect it'd be wrong to punt and let the consumer decide which tradeoff to make via a setting, but now that's exactly what I wish I could do for my current use case. -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
