import from a database / a string
Harald Massa
cpl.19.ghum at spamgourmet.com
Tue Oct 28 09:59:35 EST 2003
Hello,
since some time I try to find a more elegant solution:
modules of an application are stored in a database, and depending on the
logged on user different modules are integrated into the application.
actually I store the source-code in big text fields, get it and integrate
it via compile and execute.
c=getCodeFromDatabase(identifier)
obj=compile(c,'<ausdb>','exec')
exec obj in globals()
(with some try: and excepts:)
there could be some improvements by not executing in globals() ... but
I assume, there should be a better solution with the new import-
flexibility.
So I like to compile my module to an .pyo, store this .pyo into the
database, and do something like
import modulefromdatabase as specialname
I just can't figure out how, some materials about the new importhooks did
not help, neither did googling... can somebody push me in the correct
direction?
Harald
More information about the Python-list
mailing list