Hi,
I'm using Python 2.5 to develop a simple MVC framework based on
mod_python. To load my controllers, I create new modules using the
"new" module like this:
# ....
my_module = new.module("ran dom_name")
my_module.__fil e__ = module_path
exec open(module_pat h, "r") in my_module.__dic t__
then I initialize the class defined inside the module and call a method
of this class based on the HTTP request.
All works fine but the imports. If my module contains something like
this:
import something
class MyController(Co ntroller):
def index(self):
something.do_so mething()
when MyController.in dex is called an exception is raised "NoneType
object has not attribute do_something". Why does it happen ? I have to
load the module in different ways (but I'd like to force the reload
every time the module is loaded) ?
Gabriele 2 1321
GabrieleI'm using Python 2.5 to develop a simple MVC framework based
Gabrieleon mod_python. To load my controllers, I create new modules
Gabrieleusing the "new" module like this:
Gabriele# ....
Gabrielemy_modu le = new.module("ran dom_name")
Gabrielemy_modu le.__file__ = module_path
Gabrieleexec open(module_pat h, "r") in my_module.__dic t__
Gabrielethen I initialize the class defined inside the module and call
Gabrielea method of this class based on the HTTP request.
Why use the new module? Why not call __import__() or execfile()? Details
on their use are here: http://docs.python.org/dev/lib/built-in-funcs.html
Skip sk**@pobox.com wrote:
GabrieleI'm using Python 2.5 to develop a simple MVC framework based
Gabrieleon mod_python. To load my controllers, I create new modules
Gabrieleusing the "new" module like this:
Gabriele# ....
Gabrielemy_modu le = new.module("ran dom_name")
Gabrielemy_modu le.__file__ = module_path
Gabrieleexec open(module_pat h, "r") in my_module.__dic t__
Gabrielethen I initialize the class defined inside the module and call
Gabrielea method of this class based on the HTTP request.
Why use the new module? Why not call __import__() or execfile()? Details
on their use are here:
http://docs.python.org/dev/lib/built-in-funcs.html
Or why not use mod_python.apac he.import_modul e() from mod_python
itself. It is designed as a way of users importing specific modules,
including the capability for modules to be reloaded if they have been
changed. See: http://www.dscpl.com.au/wiki/ModPyth...oduleImporting
as well as the mod_python documentation.
Is recommended though to use mod_python 3.3 as soon as you can though
if you want the module reloading to always work. You can find
descriptions of problems with the module reloading in older versions of
mod_python at: http://www.dscpl.com.au/wiki/ModPyth...ortingIsBroken
Note that module importer in mod_python 3.3 has been enhanced some what
over prior versions in addition to fixing problems. An important new
feature is being able to load modules based on their path with modules
with same names in different directories being properly distinguished,
something which is quite useful where modules are used in web
applications to represent pages. You may want to look at documentation
for it at: http://www.modpython.org/live/mod_py...pi-apmeth.html
Graham This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: z0mb1e_fr |
last post by:
I am writing a script to change a router config.
The config is long and the result is that the display stops with a
"--more--".
Normally we type return to go to a new line or the space bar to go to
scroll down a page.
So far I failed to simulate this behaviour with expect.
The program performs a loop with:
|
by: Philipp |
last post by:
Hi, I am quite sure this question has answered here already several
times, but I haven't found the answer yet. Anyway, here is the
question again:
I've got libraries (*.so) that are built with gcc 2.95.2. The gcc
version, I've installed on my computer, is 3.xx and I don't have the
source files of the libraries. Can I link those libraries without
uninstalling my new 3.xx-compiler?
Thanx for your answers in advance. Isn't there a secret...
|
by: Leslaw Bieniasz |
last post by:
Cracow, 28.10.2004
Hello,
I have a program that intensively allocates and deletes lots
of relatively small objects, using "new" operator. The objects
themselves are composed of smaller objects, again allocated using "new".
From my tests I deduce that a considerable part of the computational
time is spent on the memory allocation, which makes the program
substantially slower compared to the equivalent code written using
|
by: Rv5 |
last post by:
Rookie c++ question, but Ive spent the last 5 years doing Java, where
everytime I created an object I used new. In c++ I can create my objects
without and its confusing me just a little.
I have a class called polynomial. Its a nothing little class right now,
with just int variables, a basic container class. Im using it as I go
through some tutorials, but in this particular tutorial its telling me to do
polynomial *first = new...
|
by: sven_c_t |
last post by:
Hi!
Probably a newbie question. I´ve been working a bit with the widget
toolkit FLTK and I have been wondering why there is such a heavy use of
the new operator, when it does not seem to be nessesary (at least to
me). What follows is an example taken from the FLTK tutorial:
-------------
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
| |
by: PengYu.UT |
last post by:
Hi,
I saw the following code:
Composition *quick = new Composition(new SimpleCompositor);
SimpleCompositor and Composition are both classes.
My question is how to delete the newed SimpleCompositor object.
|
by: Ben R. |
last post by:
I'm curious about the differeng behavior of the "new" keyword when dealing
with value versus object types. If I'm correct, when I do:
dim x as integer
There's no need for "new" to be called since this "value" type is all set to
go. Is this because value types are stored on the stack so the memory
initialization is already taken care of?
Now, when dealing with an object type, it seems you do need to use the "new"
|
by: M O J O |
last post by:
Hi,
Instead of doing this....
Public Class Form1
Public Shared Sub CreateAndShow()
Dim f As New Form1
f.Show()
End Sub
|
by: Medvedev |
last post by:
i see serveral source codes , and i found they almost only use "new"
and "delete" keywords to make they object.
Why should i do that , and as i know the object is going to be destroy
by itself at the end of the app
for example:
class test
{
public:
int x;
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |