Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15019
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'oct': 0.02; 'frameworks': 0.04; 'subject:Python': 0.06; '"""': 0.07; 'python': 0.08; 'higher-level': 0.09; 'received:209.85.160.174': 0.09; 'received :mail-gy0-f174.google.com': 0.09; 'output': 0.10; '42,': 0.16; 'simplified': 0.16; 'subject:function': 0.16; 'templating': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'cheers,': 0.18; 'insert': 0.19; 'cc:no real name:2**0': 0.20; 'subject:data': 0.21; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; '(though': 0.23; 'somehow': 0.23; 'pm,': 0.24; 'variable': 0.24; 'fine': 0.26; 'bit': 0.28; 'problem': 0.28; 'accessible': 0.29; 'explicitly': 0.29; 'module.': 0.29; 'message- id:@mail.gmail.com': 0.29; 'print': 0.29; 'script': 0.29; 'cc:addr:python.org': 0.30; 'chris': 0.32; 'pure': 0.32; 'there': 0.33; 'quite': 0.34; 'all.': 0.34; 'received:209.85.160': 0.35; 'doing': 0.36; 'issue': 0.36; 'another': 0.37; 'example,': 0.37; 'using': 0.37; 'but': 0.37; 'something': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'getting': 0.39; 'data': 0.39; 'happens': 0.40; 'more': 0.60; 'your': 0.61; '26,': 0.67; 'afraid': 0.71; 'fragment': 0.84; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=QkkWLnM52Bz5X8Rrd2PhuSJmyKXqGKBKhM3VC8fYQOQ=; b=JKnm872gkKgMVMAYi4Uw/E+mOrUwpxzIMYeW1beUbdN3V0ZNfpO3BJjP73i248VyPR cLjAD3WmYkCi+3CtKPruh/C2jtA07aDkQ7N3tpv4bbBtgC07uAHa6orSOOBknR0hAorI Kz1kIvPzCpwcvReySiKUc6tOGoIcX6w75LqIs= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <CACrcdXsXUkLWtkwYADMF-wMjsKjL7VCcSaKW-Y9D83_7Ox5-OQ@mail.gmail.com> |
| References | <CACrcdXvi6NDY5CM_AqH0BB6CVx8TRbTBjATu4kbYbcyBJfJNwQ@mail.gmail.com> <CAMuTYXhjuYuouX7+u5h1bE43x9ceWm9aUZ5CoDtu0c2Geuz8ZA@mail.gmail.com> <CACrcdXsXUkLWtkwYADMF-wMjsKjL7VCcSaKW-Y9D83_7Ox5-OQ@mail.gmail.com> |
| Date | Wed, 26 Oct 2011 19:42:09 -0700 |
| X-Google-Sender-Auth | -dRlTn6iMzLO-r8xDcrb8uhNU9I |
| Subject | Re: passing Python data to a javascript function |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Bill Allen <wallenpb@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2244.1319683332.27778.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1319683332 news.xs4all.nl 6981 [2001:888:2000:d::a6]:35459 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:15019 |
Show key headers only | View raw
On Wed, Oct 26, 2011 at 7:25 PM, Bill Allen <wallenpb@gmail.com> wrote:
>
> Benjamin,
>
> I was afraid I was doing that. I have simplified it quite a bit, still not
> getting the output I am looking for. I am down to that I am not passing
> the value in the onload=showPID() call correctly. I know this is getting a
> bit far from a Python issue now, but if you have more insight on this, I
> would appreciate it. Is there another way of passing the data from the
> Python script to the javascript than what I am doing in this CGI?
The problem is that you're not passing the data at all. You never
interpolate the pid_data value into the string(s) constituting your
embedded JavaScript (though you did do it just fine in the pure HTML).
The Python variable `pid_data` is not somehow magically accessible to
JavaScript; you must explicitly insert its value somewhere.
<snip>
> pid_data = str(os.getpid())
<snip>
> print """
<snip>
> <body onload="showPID(pid_data)">
Change that line to:
<body onload="showPID("""+pid_data+""")">
As an example, if the PID happens to be 42, then the outputted
fragment will end up being:
<body onload="showPID(42)">
As a sidenote, I would recommend using something higher-level than the
`cgi` module. Python has an abundance of web frameworks and templating
languages; take your pick.
Cheers,
Chris
--
http://rebertia.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: passing Python data to a javascript function Chris Rebert <clp2@rebertia.com> - 2011-10-26 19:42 -0700
csiph-web