Regarding storing the class in the session is not a problem that work fine
for me(need to be careful some things can't be pickel), the problem is
re-write it at each call,
I already try something similar to
order = session.order or Order()
I did,
if not isinstance("session.order",Order):
session.order=Order()
that didnt work session.order look always like empty to the validation,
since a python module just get imported once, if I move the class out of the
models in the web2py and put it in a file and imported something
from Order import *
Maybe thats work.
Any other ideas how to do this?
BTW: Thanks for the help if in the mean while i figure this one out I will
post it here.
Regards
Rui Gomes
On Thu, Mar 24, 2011 at 3:51 PM, Jonathan Lundell <[email protected]>wrote:
> On Mar 24, 2011, at 8:25 AM, Anthony wrote:
> > There is an additional problem, though. According to Massimo, web2py
> cannot store instances of classes in the session:
> https://groups.google.com/d/msg/web2py/dmN54cpMuXo/lufvxmaQMLUJ. Perhaps
> Massimo has more to say regarding this example.
> >
>
> This is what Massimo wrote in that thread:
>
> > In web2py you cannot store instances of objects into session. While
> > Armin makes it tool like this is a web2py problem this is more complex
> > and general than that. In Python if you pickle and object that is
> > instance of a class defined in /path1/mymodule.py and then you
> > unpickle on a different installation where the class is defined in /
> > path2/mymodule.py you may run into problems. Because web2py does not
> > require installation (it is a feature) and has hot plug and play of
> > apps (another feature) we cannot pickle instances (the price we pay
> > for those features). To me it is worth it.
>
> I'd like to know a little more as well. It seems to me that since sessions
> are relatively transient (you're not going to preserve sessions if you move
> web2py elsewhere), the path to the class isn't going to change between
> session accesses.