Joe, thanks for this.
I havent been able to port my app to py4web yet. So i have to step into
python3 first.
Cheers,
El Friday, January 1, 2021 a la(s) 6:45:16 PM UTC-5, Joe Barnhart escribió:
> Here is a patch that restores redis3 sessions for my system. I'm using
> the latest web2py 2.21.1 and redis stable 6.0.9 (via brew)
>
> *diff --git a/gluon/contrib/redis_session.py
> b/gluon/contrib/redis_session.py*
> *index 6413b52a..73c20422 100644*
> *--- a/gluon/contrib/redis_session.py*
> *+++ b/gluon/contrib/redis_session.py*
> *@@ -13,7 +13,7 @@ from gluon import current*
> * from gluon.storage import Storage*
> * from gluon.contrib.redis_utils import acquire_lock, release_lock*
> * from gluon.contrib.redis_utils import register_release_lock*
> *-from gluon._compat import to_native*
> *+from gluon._compat import to_native,to_bytes*
> * from datetime import datetime*
>
> * logger = logging.getLogger("web2py.session.redis")*
> *@@ -208,7 +208,7 @@ class MockQuery(object):*
> * if rtn:*
> * if self.unique_key:*
> * # make sure the id and unique_key are correct*
> *- if rtn['unique_key'] == to_native(self.unique_key):*
> *+ if rtn['unique_key'] == to_bytes(self.unique_key):*
> * rtn['update_record'] = self.update # update
> record support*
> * else:*
> * rtn = None*
>
>
> Does anyone know how to make code blocks in this new stupid Google Groups
> window? Sheesh. One step sideways and three steps back.
>
> -- Joe
>
> On Wednesday, September 11, 2019 at 12:11:13 AM UTC-5 Massimo Di Pierro
> wrote:
>
>> :-)
>>
>>
>> On Monday, 9 September 2019 22:40:36 UTC-7, Joe Barnhart wrote:
>>>
>>> ROFL! I don't think it's quite ready for my prime-time cash-producing
>>> website yet. I'll definitely keep an eye on it and start playing around
>>> with it. I need to keep you from making any decisions I don't like, after
>>> all!
>>>
>>> -- Joe
>>>
>>>
>>> On Monday, September 9, 2019 at 8:48:54 PM UTC-7, Massimo Di Pierro
>>> wrote:
>>>>
>>>> py4web supports redis. Just saying. ;-)
>>>>
>>>> On Monday, 9 September 2019 09:27:20 UTC-7, Joe Barnhart wrote:
>>>>>
>>>>> I sure wish somebody could fix this. It's a real bottleneck to
>>>>> Python3 adoption for my site. I tried using local storage for sessions
>>>>> but
>>>>> the limitation on data size makes it a no-go for my site. If I can't use
>>>>> redis I'll have to drop back to storing sessions in files and that really
>>>>> sucks for a larger deployment.
>>>>>
>>>>> -- Joe
>>>>>
>>>>> On Monday, April 1, 2019 at 11:31:10 PM UTC-7, Massimo Di Pierro wrote:
>>>>>>
>>>>>> we could change True/False with 1/0 but a better approach would be to
>>>>>> remove the value within the redis adapter. The value of locked does not
>>>>>> do
>>>>>> anything anyway on redis since it is not a relational database with
>>>>>> transactions.
>>>>>>
>>>>>> On Sunday, 31 March 2019 10:19:20 UTC-7, Jim S wrote:
>>>>>>>
>>>>>>> I changed the following in gluon/globals.py and mine is working
>>>>>>> now. But, I'm unclear on how to test to see if it is handling the
>>>>>>> locking
>>>>>>> properly:
>>>>>>>
>>>>>>> dd = dict(locked=False,
>>>>>>> client_ip=response.session_client,
>>>>>>> modified_datetime=request.now,
>>>>>>> session_data=session_pickled,
>>>>>>> unique_key=unique_key)
>>>>>>>
>>>>>>> to
>>>>>>>
>>>>>>> dd = dict(locked='False',
>>>>>>> client_ip=response.session_client,
>>>>>>> modified_datetime=str(request.now),
>>>>>>> session_data=session_pickled,
>>>>>>> unique_key=unique_key)
>>>>>>>
>>>>>>> This makes all my stuff work (I'm still on Python 2.7 but I think
>>>>>>> the problem has to do with the python redis client moving to version 3).
>>>>>>>
>>>>>>> Leonel - I think this relates back to an issue you commented on late
>>>>>>> last year.
>>>>>>> https://groups.google.com/forum/?pli=1#!searchin/web2py/redis%7Csort:date/web2py/PdquGF_9a2E/6VJpLqsnBgAJ
>>>>>>>
>>>>>>> At that time I just continued using python redis 2.10.6. But, can't
>>>>>>> do that forever. Anyone able to test or improve upon the change I made
>>>>>>> above? Like I said, it works for me, but I don't know how to see if
>>>>>>> I'm
>>>>>>> causing any other unforeseen damage.
>>>>>>>
>>>>>>> -Jim
>>>>>>>
>>>>>>> On Friday, March 29, 2019 at 7:49:03 PM UTC-5, Joe Barnhart wrote:
>>>>>>>>
>>>>>>>> Hi Leonel --
>>>>>>>>
>>>>>>>> My brain refuses to put together the words "session locked field".
>>>>>>>> I understand the part of pickle smashing the values and encoding them
>>>>>>>> as
>>>>>>>> one string. The bool has something to do with session locking?
>>>>>>>>
>>>>>>>> I've only looked at the web2py redis code in the most scant way as
>>>>>>>> I wasn't planning to become a redis expert. Sessions in redis could
>>>>>>>> be
>>>>>>>> important to me, tho, so I may need to set aside some time to dig into
>>>>>>>> it.
>>>>>>>> (Storing sessions in cookies has been problematic due to the limited
>>>>>>>> space
>>>>>>>> for cookies in browsers.)
>>>>>>>>
>>>>>>>> -- Joe
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wednesday, March 27, 2019 at 4:49:25 PM UTC-7, Leonel Câmara
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> It's not your values Joe, pickle serializes them as a string so
>>>>>>>>> they would be fine. It's web2py session locked field which is True or
>>>>>>>>> False. It's probably easy to fix this in redis_session.py
>>>>>>>>>
>>>>>>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/1041dbf3-af8c-43f5-be67-5a737cd19656n%40googlegroups.com.