Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
The trouble with __import__( 'pkg', {}, {}, [''] )
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mrts  
View profile  
 More options Aug 8 2008, 9:51 pm
From: mrts <m...@mrts.pri.ee>
Date: Fri, 8 Aug 2008 18:51:37 -0700 (PDT)
Local: Fri, Aug 8 2008 9:51 pm
Subject: The trouble with __import__( 'pkg', {}, {}, [''] )
...is http://bugs.python.org/issue2090 . This is a common idiom for
importing modules dynamically in Django.

To verify that this really is the case, create e.g. a custom
middleware as follows:

---
middleware/__init__.py:

print "EmptyMiddleware imported."

class EmptyMiddleware(object):
  def process_request(self, request)
     pass
---

which results in:

Django version 1.0-alpha_2-SVN-8255, using settings 'foo.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
EmptyMiddleware imported.
EmptyMiddleware imported.
[08/Aug/2008 21:40:10] "GET / HTTP/1.1" 200 3396


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ramiro Morales  
View profile  
 More options Aug 9 2008, 8:34 am
From: "Ramiro Morales" <cra...@gmail.com>
Date: Sat, 9 Aug 2008 09:34:19 -0300
Local: Sat, Aug 9 2008 8:34 am
Subject: Re: The trouble with __import__( 'pkg', {}, {}, [''] )

On Fri, Aug 8, 2008 at 10:51 PM, mrts <m...@mrts.pri.ee> wrote:

> ...is http://bugs.python.org/issue2090 . This is a common idiom for
> importing modules dynamically in Django.

Oh __import__ with [''] as the fouth parameter, I had the following message in
draft for the "post_save signal triggered twice" [1]thread a couple of week ago
and never dare to send it (I've update the grepping over the tree to current
trunk status):

Regarding the use of __import__, there are some notes in [2]ticket 6579 about
calling it with a empty string as the fourth parameter having the effect of
initializing the module twice (there is also a [3]link to a ticket in the
Python bug tracker.)

When [4]pointed to it in a comment to #6587, Øyvind Saltvik
implemented another loading strategy in the latest patch for that ticket.

All this in the context of (the maybe 1.0 feature) of removing the hacks in the
template tag loading code, but could this also be related to the repeated
triggering of signals?

Searching over the Django code as of r8255 [5]finds 28 occurrences of such a
pattern, some of them when loading user project or application code from the
Django core.

Regards,

--
 Ramiro Morales

1. http://groups.google.com/group/django-developers/browse_frm/thread/c1...
2. http://code.djangoproject.com/ticket/6579
3. http://code.djangoproject.com/ticket/6579#comment:6
4. http://code.djangoproject.com/ticket/6587#comment:10
5. http://dpaste.com/hold/70347/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Illarionov  
View profile  
 More options Aug 9 2008, 3:17 pm
From: Ivan Illarionov <ivan.illario...@gmail.com>
Date: Sat, 9 Aug 2008 12:17:22 -0700 (PDT)
Local: Sat, Aug 9 2008 3:17 pm
Subject: Re: The trouble with __import__( 'pkg', {}, {}, [''] )
I submitted a patch[1] that fixes this problem.

[1] http://code.djangoproject.com/attachment/ticket/8193/import_fixes_827...

On Aug 9, 5:51 am, mrts <m...@mrts.pri.ee> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »