import from a database / a string

H

Harald Massa

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top