I've found the issue, it's not web2py related, sorry about that.
My web2py instance has several applications running, each one is attached
to a domain.
I store a the map of domains:apps in a dictionary that I save to a .pkl
file.
Then my routes.py reads that file and loads the map of domains:apps
I write the .pkl file like this:
with open('map.pkl', 'wb') as file:
pickle.dump(dictionary_map, file, protocol=2)
Notice I use protocol=2 because I want to be able to read/write the file
with python 2 and 3.
In my routes.py I read the file like this:
map = pickle.load(open('domains_apps.pkl', 'rb'))
routers = dict(
BASE=dict(
default_controller='default',
default_function='index',
domains=map,
map_static=True,
exclusive_domain=True,
)
)
However, after writing .pkl the file with python 3 and returning to python
2, my applications fail with the error reported in my first message. The
error goes away if I replace the .pkl file with an old backup I had made
before using python 2.
I have noticed that once the .pkl file is written with python 3, then
reading it with python 2 and 3 throws different results:
*with python 3*:
>>> r = pickle.load(open('domains_apps.pkl', 'rb'))
>>> print(r)
{'prod.com': 'prod', 'test.com': 'test'}
*with python 2*:
>>> r = pickle.load(open('domains_apps.pkl', 'rb'))
>>> print(r)
{*u*'prod.com': *u*'prod', *u*'test.com': *u*'test'}
Notice that in python 2 reading the .pkl file (that was written with python
3 using protocol=2) returns unicode strings. This doesn't happen in python
3. But i'm not sure what protocol to use.
I'll do some more tests and I'll post here whatever solution I can find.
Thanks for your time!
Regards,
Lisandro.
El jueves, 10 de octubre de 2019, 21:21:53 (UTC-3), Dave S escribió:
>
> Delete all the .pyc files?
>
>
> /dps
>
--
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/7ea86508-b90f-4197-96a8-11a1f7ecbdb5%40googlegroups.com.