Re: Running Inline::Python in a CGI script

[email protected] (Chris Nighswonger)
Newsgroups perl.inline
Message-ID <CAP3yOonPmagXAQh7Mk=WChuh3Rrr1JnowO68o08BAeisc2SVGA@mail.gmail.com>
On Thu, Mar 14, 2013 at 8:04 AM, Stefan Seifert <[email protected]> wrote:

> On Tuesday 12 March 2013 11:15:40 Chris Nighswonger wrote:
> > 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 necessary for Python to
> load
> the package.
>

That was most of it. Here is what finally worked:

use Inline::Python qw( py_new_object py_call_method );
use Inline  Python   => 'DATA',
            DIRECTORY   => '/usr/share/webmin/pykota/.Inline/';

Inline->init();

my $pykota_conf = py_new_object("PyKotaConfig", "pykota.config",
"PyKotaConfig", '/etc/pykota/');

print "Admin mail for the AP400N: " . py_call_method($pykota_conf,
"getAdminMail", 'AP400N') . "\n";

I ended up having to use py_call_method rather than Perl's method syntax.
Maybe I just missed something else about that along the way.

Many thanks to Stefan and Rob for the help and bearing with me.

And thanks for a very cool module which will hopefully save me loads of
execution time over making system calls.

Kind Regards,
Chris
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.