473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to tell the parent frame is a C module? (Lazy importing)

Hello all,
I've been working on a lazy import module to be found here:
http://aspn.activestate.com/ASPN/Coo.../Recipe/473888

The basic idea is that a module proxy for foo is returned from an
'import foo' statement. When an attribute of foo is accessed, or
dir(foo) is called, or a from foo import * is done, the module is
actually loaded, and the module proxy is replaced in the calling
frame. This relies on the proxy being able to intercept __getattr__,
etc from the module and behaving appropriately.

This seems to work very well except in the case where the importing
module is a C module.

When getting the attributes of a class in C, python does the following check:

if (!PyModule_Check(m)) {
PyErr_BadInternalCall();
return NULL;
}
d = ((PyModuleObject *)m) -> md_dict;

Which does an end-run around all of my module-related evilness.

I'm hoping that there is some way to somehow detect when the import
statement is being called from a C module, and in that case just load
the module normally. But I can't figure out any way to detect that
from python. In fact, in sys.frame it looks like any C modules are
simply skipped over. I could try to detect that an intermdiate frame
is missing, I suppose....

Any pointers?
Dave
Feb 15 '06 #1
0 953

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stuart Wexler | last post by:
Let's say I have a frameset page and I want to preselect an option in a select box from the parent frame. So the parent frame would programmatically change the select box in the child frame. ...
2
by: Amadelle | last post by:
Hi all, I have multiple frames which I would like to get the query string from within one of the subframes. But when I do HttpContext.Current.Request.QueryString or Request.QueryString ...
18
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. ...
3
by: Zachary Pincus | last post by:
Hi folks, I'm sure this has come up before, but the search terms I've been using are so non-specific that I can't get any traction on Google. Here's my question: I have written a subclass of...
9
by: noamsml | last post by:
Hi, I am new to python and am currently writing my first application. One of the problems I quickly ran into, however, is that python's imports are very different from php/C++ includes in the...
4
by: rshepard | last post by:
I'm stymied by what should be a simple Python task: accessing the value of a variable assigned in one module from within a second module. I wonder if someone here can help clarify my thinking. I've...
5
by: dg.google.groups | last post by:
Hi all, Is there any standard way to tell if the user is running from a module or from an interactive shell like IDLE or IPython? The best I've come up with so far is for a function to look at...
1
by: Ryan Krauss | last post by:
I am trying to call a parent's __init__ method from the child's: class ArbitraryBlock(InnerBlock): def __init__(self, codelist, noout=False, **kwargs): InnerBlock.__init__(self, codelist,...
1
by: michal.podlewski | last post by:
Hi All, I have a problem with a simple (as I thought till now) thing: I want to make a link in a child-window which would change site in the parent-window and along with closing child window. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.