Re: Running Inline::Python in a CGI script

[email protected] (Stefan Seifert)
Newsgroups perl.inline
Message-ID <[email protected]>
On Tuesday 12 March 2013 11:15:40 Chris Nighswonger wrote:
> On Tue, Mar 12, 2013 at 9:43 AM, Stefan Seifert <[email protected]> wrote:
> > # 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();
> 
> So here's my shot at this:
> 
> use Inline::Python qw( py_new_object );
> 
> my $pykota_conf = py_new_object("config", "pykota.config", "PyKotaConfig",
> '/etc/pykota/');
> print "Admin mail for the AP400N: " . $pykota_conf->getAdminMail('AP400N')
> . "\n";

You're missing the import statement. It's still neccessary for Python to load 
the package. Try:

use Inline::Python qw( py_new_object );
use Inline::Python => <<'PYTHON';
    import pykota.config
PYTHON

my $pykota_conf = py_new_object("config", "pykota.config", "PyKotaConfig",
'/etc/pykota/');
print "Admin mail for the AP400N: " . $pykota_conf->getAdminMail('AP400N')
. "\n";


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

iEYEABECAAYFAlFBvNYACgkQ1QuEJQQMVrhzcQCdEU3Udo9y9XD3kQIiY9TCKSgD
y0cAmwfozj93VpYATObEJ5RJa714gplP
=JK4D
-----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.