Ok, I found my problem.

Because I was storing a object into the session dictionnary, when I called
method to add, modify or delete object's value, the session didn't get
saved.



2007/10/31, Francis Lavoie <[EMAIL PROTECTED]>:
>
> But Isn't the same thing as saving the object in the
> request["session"]["myobject"] ?.
>
> The dictionnary is not being erase entirely, but it is the associate value
> that are reset to empty string. I though at first that I might trigger the
> __init__ , but when I trace it, the object is not being reinitialyse.
>
> Is it possible that the object is only keep in memory because I use a
> third level method to assign the values?
>
> class object1:
>    def __init__(self):
>        self.key1 = object2()
>
> class object2:
>    def do2(self, v):
>        self.key2 = { "value": v }
>
> In views.py I do :
>
> myobj = object1()
> myobj.key1.do2("value")
>
>
>
> 2007/10/30, Malcolm Tredinnick <[EMAIL PROTECTED]>:
> >
> >
> > On Tue, 2007-10-30 at 16:40 -0400, Francis Lavoie wrote:
> > > Hi,
> > >
> > >
> > > I have a shopping_cart class that I use with a session to store orders
> >
> > > information.
> > >
> > >
> > > In this shopping cart, I have other object like customer contact.
> > >
> > >
> > > class CustomerContact:
> > >     def __init__(self):
> > >         self.address = {}
> > >
> > >     def add_address(self, add_dict, Company, Contact, Address, City,
> > > State, Zip, Country, Phone, Fax, Email):
> > >         self.address[add_dict] = { "Company" : Company,  "Contact" :
> > > Contact,
> > >                                                     "Address" :
> > > Address, "City" : City,
> > >                                                     "State" :
> > > State,  "Zip" : Zip,
> > >                                                     "Country" :
> > > Country, "Phone" : Phone,
> > >                                                     "Fax" :
> > > Fax, "Email" : Email }
> > >
> > >
> > > it is quite basic.
> > >
> > >
> > > In my shopping cart I assign a variable to this object in __init__.
> > >
> > >
> > > Step 1.  User fill the address required fields, then commit, it will
> > > set three addresses [add_dict] for billing, shipping, other
> > > To set the address I
> > > use : 
> > > request.session['shopping_cart'].customer_contact.add_address("billing",
> > alltheinfo)
> > >
> > >
> > > Step 2. It display a payment page which also shows the filled address.
> > > Address are display correctly
> > >
> > >
> > > Step 3. Then it display a validation page. My dictionnary is somehow
> > > reset, the keys are still there but nothing is assign to it.
> > >
> > >
> > >
> > >
> > > Is my logic erroneous? I just dont understand why my dictionnary get
> > > reset between step2 and step3.
> >
> > At step 1 you fill in something in memory. You then return to display a
> > new page to the user. So between step 1 and step 2, all information in
> > memory is effectively lost. Once the user submits the form in step 2, it
> >
> > might not even be the same process that is handling the reply, since web
> > servers can use multiple processes and/or threads to handle requests.
> >
> > So you need to save the data after step 1. Since this a Django mailing
> > list, I'd suggest using a Django model and saving it to the database.
> >
> > Regards,
> > Malcolm
> >
> > >
> > --
> > The early bird may get the worm, but the second mouse gets the cheese.
> > http://www.pointy-stick.com/blog/
> >
> >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to