hello,
I've a class, that reads a huge file and parses it.
Therefor I want just one instance per session or even one over all sessions.
# The next code (placed in controler default.py) generates an error
if session.Book_Loaded is None :
session.Book_Loaded = PuntHoofd_support.PuntHoofd_Doc ( Text )
session.Test_One_Instance = random.randint ( 0, 1000 )
Book_Source = session.Book_Loaded
Test_One_Instance = session.Test_One_Instance
#Chapters = Test_One_Instance.Get_Chapters ( Book )
#AttributeError: 'str' object has no attribute 'Get_Chapters'
Error: session.Book_Loaded has become a string ????
Now I've found a workaround that does work:
try :
sys.Book_Loaded
except :
sys.Book_Loaded = PuntHoofd_support.PuntHoofd_Doc ( Text )
sys.Test_One_Instance = random.randint ( 0, 1000 )
Book_Source = sys.Book_Loaded
Test_One_Instance = sys.Test_One_Instance
Is there a better/cleaner way to realize this ?
thanks,
Stef
--
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.