Re: [pylons-discuss] Strange problem with request method

2021-10-11 Thread Gerhard Schmidt
Hi, I think i fixed the problem. The error was a wrong import when registering the request method. The import worked within the ide envoirement but not outside and inside the ide in porduced this strange behavior. Regards Estartu Am 11.10.21 um 18:58 schrieb Mike Orr: Where is the

Re: [pylons-discuss] Strange problem with request method

2021-10-11 Thread Gerhard Schmidt
Hi Michael, there is a code to fill the cache. I spend 3 hours debugging this. Importing and calling the method directly works perfectly well. If i call it in the next line in code via request object the cache is empty. The first call produces a log entry with the correct package. The call

Re: [pylons-discuss] Strange problem with request method

2021-10-11 Thread Mike Orr
Where is the cache stored, and which Lock class are you using? Application globals are tricky in Pyramid. One place you can store them is a registry attribute (request.registry.myattr); I use this for SQLAlchemy engines. Or you could stuff it into the configuration settings at startup. The

Re: [pylons-discuss] Strange problem with request method

2021-10-11 Thread Michael Merickel
I think there's a lot of unknowns in helping unpack this - for starters there's no code supplied that actually modifies the cache, so of course it is empty! - There's a few gotchas in python - for example if this is done in the main file in your app (foo.py) and you run "python -m foo" then the

[pylons-discuss] Strange problem with request method

2021-10-11 Thread Gerhard Schmidt
Hi, today I encountered a very strange problem with request methods. <--- code ---> cache = {'agents': set(), 'time': 0.0} cache_lock = Lock() def in_agent_cache(request): with cache_lock: return request.user_agent in cache['agents'] <--- end code ---> If I call the