Dear Massimo ,
in one of my applications , that has a shopping cart in the controller i
have :
# Here i create a number that will never happen again ! and save it in the
session and i use it in the database to get the cart items
def store():
import random
if session.order == None :
cart_ID = random.randint(0,999999)
ip= (request.client).replace(".","")
session.CartID = str(cart_ID) + str(ip)
session.order = "True"
cartItems = db(db.cart.OrderID == session.CartID).select(db.cart.ALL)
if request.args(0) == "Brand" :
sup = db(db.Supplements.Brand_ID ==
request.args(2)).select(db.Supplements.ALL)
else:
sup = db((db.Supplements.Category ==
(request.args(1)).replace('_',' ')) & (db.Supplements.Users ==
request.args(0))).select(db.Supplements.ALL)
return locals()
# Here is the add to cart where i use that session and add it to the
database
def AddToCart():
if request.vars:
# Fetching Varibles
id = request.vars.id
q = request.vars.quantityinput
type = request.vars.type
#checking If item in alrady in cart
if int(id) in cartlist:
cartitem =
db.cart((db.cart.OrderID==session.CartID)&(db.cart.ProductID==id))
cartitemid = db.cart[cartitem.id]
cartitemid.update_record(quantity = int(cartitem.quantity) +
int(q))
session.flash = 'Already in cart'
else:
db.cart.insert(OrderID=session.CartID,ProductID=id,quantity=q,catid=type)
session.flash = "Added"
redirect(URL('product',args=[request.vars.one,request.vars.two]))
May be somthing here is making that error !!
Best Regards
Hasan Alnatoru
On Friday, October 12, 2012 4:45:55 PM UTC+3, Massimo Di Pierro wrote:
>
> Are you storing session in db?
>
> On Friday, 12 October 2012 01:58:24 UTC-5, Hassan Alnatour wrote:
>>
>> Dear Massimo ,
>>
>> I tried the nightly build as you said and i still get errors :
>>
>> TRACEBACK
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>>
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>>
>> Traceback (most recent call last):
>>
>> File "C:\web2py\gluon\main.py", line 565, in wsgibase
>>
>>
>> session._try_store_on_disk(request, response)
>>
>>
>> File "C:\web2py\gluon\globals.py", line 703, in _try_store_on_disk
>>
>>
>> cPickle.dump(dict(self), response.session_file)
>>
>>
>> File "C:\Python27\Lib\copy_reg.py", line 74, in _reduce_ex
>>
>>
>> getstate = self.__getstate__
>>
>>
>> File "C:\web2py\gluon\dal.py", line 7335, in __getattr__
>>
>>
>> self.__allocate()
>>
>>
>> File "C:\web2py\gluon\dal.py", line 7328, in __allocate
>>
>>
>> self._record = self._table[int(self)]
>>
>>
>> File "C:\web2py\gluon\dal.py", line 7615, in __getitem__
>>
>>
>> return self._db(self._id == key).select(limitby=(0,1)).first()
>>
>>
>> File "C:\web2py\gluon\dal.py", line 8768, in select
>>
>>
>> return adapter.select(self.query,fields,attributes)
>>
>>
>> File "C:\web2py\gluon\dal.py", line 2123, in select
>>
>>
>> return super(SQLiteAdapter, self).select(query, fields, attributes)
>>
>>
>> File "C:\web2py\gluon\dal.py", line 1612, in select
>>
>>
>> return self._select_aux(sql,fields,attributes)
>>
>>
>> File "C:\web2py\gluon\dal.py", line 1577, in _select_aux
>>
>>
>> self.execute(sql)
>>
>>
>> File "C:\web2py\gluon\dal.py", line 1689, in execute
>>
>>
>> return self.log_execute(*a, **b)
>>
>>
>> File "C:\web2py\gluon\dal.py", line 1683, in log_execute
>>
>>
>> ret = self.cursor.execute(*a, **b)
>>
>> ProgrammingError: Cannot operate on a closed database.
>>
>>
>>
>> regards,
>>
>>
>> On Fri, Sep 28, 2012 at 10:04 PM, Massimo Di Pierro <
>> [email protected]> wrote:
>>
>>> Many little ones. But I just want to make sure the problem has not been
>>> fixed already and we are working off the same code.
>>>
>>>
>>> On Friday, 28 September 2012 11:24:02 UTC-5, Hassan Alnatour wrote:
>>>
>>>> Dear Massimo ,
>>>>
>>>> i will try it now , but what is the difference between the
>>>> stable version and the nightly build ?
>>>>
>>>> Best Regards,
>>>> Hassan Alnatour
>>>>
>>>>
>>>>
>>>> On Fri, Sep 28, 2012 at 7:10 PM, Massimo Di Pierro <
>>>> [email protected]> wrote:
>>>>
>>>>> Can you try the web2py nightly build?
>>>>>
>>>>>
>>>>> On Friday, 28 September 2012 10:12:25 UTC-5, Hassan Alnatour wrote:
>>>>>
>>>>>> Dear Massimo ,
>>>>>>
>>>>>> i tested on early version of web2py and it works just fine , can you
>>>>>> help me with this please ?
>>>>>>
>>>>>> Best Regards,
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Friday, September 28, 2012 3:44:45 PM UTC+3, Hassan Alnatour wrote:
>>>>>>
>>>>>>> Dear Massimo ,
>>>>>>>
>>>>>>> i am getting this not in just on of my apps , and am not storing
>>>>>>> anything in the session , the only thing using it is the login and i
>>>>>>> keep
>>>>>>> getting this error when the user tries to login ..
>>>>>>>
>>>>>>> Best Regards,
>>>>>>> Hassan Alnatour
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Sep 28, 2012 at 7:39 AM, Massimo Di Pierro <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> You are storing in session something that cannot be properly
>>>>>>>> serialized.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Friday, 28 September 2012 05:47:52 UTC-5, Hassan Alnatour wrote:
>>>>>>>>
>>>>>>>>> Dear ALL ,
>>>>>>>>>
>>>>>>>>> i am having some trouble with the new web2py , i have a window
>>>>>>>>> server 2008 that i am using apache in to host my sites , now
>>>>>>>>> everything
>>>>>>>>> was working fine but when i updated web2py , it was okey but every
>>>>>>>>> once and
>>>>>>>>> while the login stops , i open the server and i do the same thing
>>>>>>>>> locally
>>>>>>>>> and i dont get any errors and i use the error trace back id and i
>>>>>>>>> dont get
>>>>>>>>> anything in the trace back , and it only works when i restart apache ?
>>>>>>>>>
>>>>>>>>> ALL the errors am getting are this :
>>>>>>>>>
>>>>>>>>> TICKET ID
>>>>>>>>>
>>>>>>>>> 37.44.32.9.2012-09-28.05-51-**54****.25cc4409-0578-4835-bfaa-**
>>>>>>>>> 5a51e****416766d
>>>>>>>>> VERSION web2py™ (2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51,
>>>>>>>>> 30), 'stable') TRACEBACK
>>>>>>>>>
>>>>>>>>> 1.
>>>>>>>>> 2.
>>>>>>>>> 3.
>>>>>>>>> 4.
>>>>>>>>> 5.
>>>>>>>>> 6.
>>>>>>>>> 7.
>>>>>>>>> 8.
>>>>>>>>> 9.
>>>>>>>>> 10.
>>>>>>>>> 11.
>>>>>>>>> 12.
>>>>>>>>> 13.
>>>>>>>>> 14.
>>>>>>>>> 15.
>>>>>>>>> 16.
>>>>>>>>> 17.
>>>>>>>>> 18.
>>>>>>>>> 19.
>>>>>>>>> 20.
>>>>>>>>> 21.
>>>>>>>>> 22.
>>>>>>>>> 23.
>>>>>>>>> 24.
>>>>>>>>> 25.
>>>>>>>>> 26.
>>>>>>>>> 27.
>>>>>>>>>
>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\main.py", line 547, in wsgibase
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> session._try_store_on_disk(req******uest, response)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\globals.py", line 686, in _try_store_on_disk
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> cPickle.dump(dict(self), response.session_file)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\Python27\Lib\copy_reg.py", line 74, in _reduce_ex
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> getstate = self.__getstate__
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 7344, in __getattr__
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> self.__allocate()
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 7337, in __allocate
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> self._record = self._table[int(self)]
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 7624, in __getitem__
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> return self._db(self._id ==
>>>>>>>>> key).select(limitby=(0,1)).fir******st()
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 8766, in select
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> return adapter.select(self.query,fiel******ds,attributes)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 2094, in select
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> return super(SQLiteAdapter, self).select(query, fields,
>>>>>>>>> attributes)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 1594, in select
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> return self._select_aux(sql,fields,at******tributes)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 1559, in _select_aux
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> self.execute(sql)
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 1671, in execute
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> return self.log_execute(*a, **b)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> File "C:\web2py\gluon\dal.py", line 1665, in log_execute
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ret = self.cursor.execute(*a, **b)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ProgrammingError: Cannot operate on a closed database.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> What do you think is the problem ? and how can i solve this ?
>>>>>>>>>
>>>>>>>>> Best Regards,
>>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>
>>>
>>>
>>>
>>
>>
--