Re: Different kinds of Import Errors

2007-12-09 Thread Jeremy C B Nicoll
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sun, 09 Dec 2007 00:25:53 +, Jeremy C B Nicoll wrote: > > > > for app_name in settings.INSTALLED_APPS: > > > try: > > > __import__(app_name + '.management', {}, {}, ['']) > > > except ImportError, exc: > >

Re: Different kinds of Import Errors

2007-12-08 Thread Steven D'Aprano
On Sun, 09 Dec 2007 00:25:53 +, Jeremy C B Nicoll wrote: > > for app_name in settings.INSTALLED_APPS: > > try: > > __import__(app_name + '.management', {}, {}, ['']) > > except ImportError, exc: > > if exc.args[0]!='No module named manageme

Re: Different kinds of Import Errors

2007-12-08 Thread Jeremy C B Nicoll
Thomas Guettler <[EMAIL PROTECTED]> wrote: > If you look at this code, you see there are two kind of ImportErrors: > > 1. app_name has no attribute or file managment.py: That's OK. > 2. managment.py exists, but raises an ImportError: That's not OK: reraise > > # Import the 'management' m

Re: Different kinds of Import Errors

2007-12-04 Thread Gabriel Genellina
On 1 dic, 02:41, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Dec 1, 12:24 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > > Sorry, but this does not work. If there is an ImportError > > during importing the existing module, it won't get inserted > > into sys.modules. I just tried it with a

Re: Different kinds of Import Errors

2007-12-04 Thread Thomas Guettler
Graham Dumpleton schrieb: > What example did you use to test it? What version of Python are you > using? Yes, this changed. Python 2.3 includes the half imported module. Python 2.4 does not. But the traceback of the exception contains the needed information: Here are the two example files: # fo

Re: Different kinds of Import Errors

2007-11-30 Thread Graham Dumpleton
On Dec 1, 12:24 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Sorry, but this does not work. If there is an ImportError > during importing the existing module, it won't get inserted > into sys.modules. I just tried it with a small example. > > An other solution would be to inspect the traceback.

Re: Different kinds of Import Errors

2007-11-30 Thread Thomas Guettler
Sorry, but this does not work. If there is an ImportError during importing the existing module, it won't get inserted into sys.modules. I just tried it with a small example. An other solution would be to inspect the traceback. If the app_name+'.management' is in it, it exists. Graham Dumpleton sc

Re: Different kinds of Import Errors

2007-11-28 Thread Peter Otten
Thomas Guettler wrote: > If you look at this code, you see there are two kind of ImportErrors: > > 1. app_name has no attribute or file managment.py: That's OK. > 2. managment.py exists, but raises an ImportError: That's not OK: reraise > > # Import the 'management' module within each in

Re: Different kinds of Import Errors

2007-11-27 Thread Graham Dumpleton
On Nov 28, 12:35 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If you look at this code, you see there are two kind of ImportErrors: > > 1. app_name has no attribute or file managment.py: That's OK. > 2. managment.py exists, but raises an ImportError: That's not OK: reraise > > # Import

Re: Different kinds of Import Errors

2007-11-27 Thread kyosohma
On Nov 27, 3:50 pm, [EMAIL PROTECTED] (Aahz) wrote: > In article <[EMAIL PROTECTED]>, > > <[EMAIL PROTECTED]> wrote: > > ># untested > >args = exc.args[0] > >if args.find('management') != -1: > >raise > > YM > > if 'management' in args: > raise > > HTH, HAND ;-) > -- > Aahz ([EMAIL PROTEC

Re: Different kinds of Import Errors

2007-11-27 Thread Aahz
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: > ># untested >args = exc.args[0] >if args.find('management') != -1: >raise YM if 'management' in args: raise HTH, HAND ;-) -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "Typing is cheap. Thin

Re: Different kinds of Import Errors

2007-11-27 Thread kyosohma
On Nov 27, 7:35 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If you look at this code, you see there are two kind of ImportErrors: > > 1. app_name has no attribute or file managment.py: That's OK. > 2. managment.py exists, but raises an ImportError: That's not OK: reraise > > # Import t

Different kinds of Import Errors

2007-11-27 Thread Thomas Guettler
If you look at this code, you see there are two kind of ImportErrors: 1. app_name has no attribute or file managment.py: That's OK. 2. managment.py exists, but raises an ImportError: That's not OK: reraise # Import the 'management' module within each installed app, to register # d