473,847 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

template is calling 2 times

hi,

i am newbie to python so i am trying to learn mod_python as my new
development kit for my small web apps.

i am getting strange result can anybody explain me.
*************** *************** *************** *************** *************** *************** ***
index.py
*************** *************** *************** *************** *************** *************** ***
from mod_python import apache
from mod_python import psp
from mod_python import util

def index(req, para=None):
tmpl = psp.PSP(req, filename='a.htm l')
tmpl.run(vars = {'para':para})
tmpl.run()

def show_data(req, name):
index(req, name)
*************** *************** *************** *************** *************** *************** ***

*************** *************** *************** *************** *************** *************** ***
a.htm
*************** *************** *************** *************** *************** *************** ***

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<BODY>
<h1><%=para%> </h1>
<form method="post" action="http://localhost:8080/test/show_data">
<input type="text" name="name">
<input type="submit">
</form>
</BODY>
</HTML>
*************** *************** *************** *************** *************** *************** ***

*************** *************** *************** *************** *************** *************** ***
Result
*************** *************** *************** *************** *************** *************** ***
None
<textbox<submit button>

Mod_python error: "PythonHand ler mod_python.publ isher"
Traceback (most recent call last):
File "E:\Python24\Li b\site-packages\mod_py thon\apache.py" , line 299, in
HandlerDispatch result = object(req)
File "E:\Python24\Li b\site-packages\mod_py thon\publisher. py", line 213,
in handler published = publish_object( req, object)
File "E:\Python24\Li b\site-packages\mod_py thon\publisher. py", line 412,
in publish_object return Publish_object( req,util.apply_ fs_data(object,
req.form, req=req))
File "E:\Python24\li b\site-packages\mod_py thon\util.py", line 439, in
apply_fs_data return object(**args)
File "E:\Apache Group\Apache2\h tdocs\test\inde x.py", line 8, in index
tmpl.run()
File "E:\Python24\Li b\site-packages\mod_py thon\psp.py", line 213, in
run exec code in global_scope
File "E:\Apache Group\Apache2\h tdocs\test\a.ht ml", line 1, in ?
NameError: name 'para' is not defined
*************** *************** *************** *************** *************** *************** **
what's wrong in this code?
any good internet resource to learn mod_python?

thanks in advanced
Sanjeev

Jul 7 '06 #1
1 1106
sanjeevdivekar a écrit :
hi,

i am newbie to python so i am trying to learn mod_python as my new
development kit for my small web apps.

i am getting strange result
Nothing strange here AFAICT.
can anybody explain me.
index.py
*************** *************** *************** *************** *************** *************** ***
from mod_python import apache
from mod_python import psp
from mod_python import util

def index(req, para=None):
tmpl = psp.PSP(req, filename='a.htm l')
tmpl.run(vars = {'para':para})
tmpl.run()
Here, you call tmpl.run() two time, the first time with a dict having an
entry named 'param', the second time without it.
a.htm
*************** *************** *************** *************** *************** *************** ***
(snip)
<BODY>
<h1><%=para%> </h1>
And here you try to display something named "para". I don't have much
knowledge of PSP, but I have enough experience to assert this try to get
the entry named "param" from the dict passed to tmpl.run().

(snip)
Result
(snip)
File "E:\Apache Group\Apache2\h tdocs\test\inde x.py", line 8, in index
tmpl.run()
Here we are : line 8 of index.py, your second call to tmpl.run() without
the dict.
File "E:\Python24\Li b\site-packages\mod_py thon\psp.py", line 213, in
run exec code in global_scope
File "E:\Apache Group\Apache2\h tdocs\test\a.ht ml", line 1, in ?
NameError: name 'para' is not defined
and here the tentative to get this name from the dict.

Doesn't seem so strange to me. Note that I could be wrong - you'd better
check in PSP documentation - but I think I'd try commenting out the
second (and AFAICT useless) call to tmpl.run().
Jul 7 '06 #2

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

Similar topics

7
2515
by: Rolf Kemper | last post by:
Dear All, somehow I remember that such or similar question was discussed already somewhere. But I can't find it anymore. I have a template calling itself. As long it goes deeper into the hierarchy (by the key) I can set the CurrentY parameter by itself + some constant correctly. Hence which each call the CurrentY gets bigger. But when the template reaches a leave and the caller is poped from
7
5953
by: Patrick Kowalzick | last post by:
Dear all, I just wondered if it is possible to count the number of classes created via a template class at compile time. To show what I mean I post an example, which is not working but carries the idea: static int counter = 0; // this variable can be changed only at runtime... template <typename T> struct want_to_be_counted;
0
987
by: Tony Johansson | last post by:
Hello! Here I have two classes these are called Handle and Body and a main. You have the class definition below. Some basic information. In the Handle class is there a pointer to the Body class. Each Body object contains one primitive datatype int. The Body instance is created in the constructor for Handle. In main I instanciate some Handle object and use the STL function push_front to push these object into the list.
22
6036
by: Ian | last post by:
The title says it all. I can see the case where a function is to be called directly from C, the name mangling will stuff this up. But I can't see a reason why a template function can't be given extern "C" linkage where it is to be assigned to a C function pointer. Ian
0
1172
by: Steve Jorgensen | last post by:
In a schema I've been working on recently, a convention I evolved was to use a consistent naming pattern such that, for instance, a Resident could appear in a ResidentSet, and could be referred to by a ResidentRef, and the same pattern would apply to other types of entities. That amounts to a lot of duplication in the schema, though, and results in a need to enforce consistency in how the naming convention is applied. A solution I've...
6
1834
by: Neal | last post by:
Hi All, I used an article on XSLT and XML and creating a TOC written on the MSDN CodeCorner. ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dncodecorn/html/corner042699.htm However, it did'nt quite answer all my questions. How would one create a 3 level TOC when each item level / node was differently named (They used Template match and for-each, but the template match worked as on a 3 level structure they usedf the same named xml...
0
1912
by: magicofureyes | last post by:
Hello Guys im a just a new user and i dnt knw much abt Xml i want to upload a new template in Blogger so got some free coding but when i save this code in Blogger template it say '''' Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The element type "Variable" must be terminated by the matching end-tag "". so please help me out and check this coding if...
13
6610
by: mike b | last post by:
Hello everyone, thanks in advance for your help. I'm new to C++ templates and have run into some issues using member function templates. I have a shared library containing templates that I'm trying to use from an executable, compile using gcc 4.1.2. Everything works fine until I try specializing one of the static member function templates in a non-template class. I have a feeling I'm messing up something obvious so before I post a...
0
1134
by: shai.halevi | last post by:
I'm looking for a simple template with the following property: I want to have in the resulting page something like this (say): <div> This is some text that never changes: ]] This is some more text that never changes </div> The crux is that if the calling code never initializes the variable,
6
391
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
0
9730
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,...
0
10983
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, 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...
1
7882
isladogs
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...
0
7056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5719
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...
0
5911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4119
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3164
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.