Re: Running Inline::Python in a CGI script

[email protected] (Stefan Seifert)
Newsgroups perl.inline
Message-ID <[email protected]>
On Monday 11 March 2013 11:20:36 Chris Nighswonger wrote:

> 2.The second version imports a class from a Python module. The script
> runs fine when called from the cli. However, it borks when executed as
> a cgi, complaining of calls to undefined functions/methods. Of course,
> those functions/methods are in the Python module.

Can you post the script code? Or at least the part dealing with Python?
When importing Inline::Python it loads and runs the given Python code 
(containing the import statements). Then it inspects the main namespace and 
imports those names into the Perl namespace. I suspect that miniserv.pl 
trickery leads to namespace problems. So could you please try the 
py_new_object() and py_call_function() way of accessing Python? This avoids 
namespace magic and should be more reliable:

# create a Python foo.Bar object and make it look like a Bar object in Perl:
my $bar = py_new_object('Bar', 'foo', 'Bar', 'constructor arg 1');
$bar->baz();

Regards,
Stefan
signature.asc (application/pgp-signature, 198 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iEYEABECAAYFAlE/MRMACgkQ1QuEJQQMVriooQCfViNhdVL43WeY+SjrfpoN/jvT
ikwAn12ov4TAyTyZ/2lBhOnUWS4Mcx1p
=a78A
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.