what about ?
def mod_import(name,request=None):
if request: name='applications.%s.modules.%s' %
(request.application, name)
mod = __import__(name)
for part in name.split('.')[1:]:
mod = getattr(mod,part)
return mod
On Jan 8, 12:23 pm, Robin B <[email protected]> wrote:
> def mod_import(name):
> mod = __import__(name)
> for part in name.split('.')[1:]:
> mod = getattr(mod,part)
> return mod
>
> T2 = mod_import('applications.%s.modules.t2'%request.application).T2
> t2=T2(request,response,session,cache,T,db)
> ...
>
> Benefits: does not modify sys.path and does not resort to exec'ing.
>
> Robin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---