Forgot to 'reply all'... sorry. ---------- Forwarded message ---------- From: Chris Nighswonger <cnighswon...@foundations.edu> Date: Tue, Mar 12, 2013 at 9:53 AM Subject: Re: Running Inline::Python in a CGI script To: Stefan Seifert <n...@detonation.org>
On Tue, Mar 12, 2013 at 9:43 AM, Stefan Seifert <n...@detonation.org> wrote: > 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? > See the Perl script below. The Python module may be seen here: http://svn.pykota.com/pykota/trunk/pykota/config.py > 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(); > I'll try this and post back the results. Kind Regards, Chris ---------- #!/usr/bin/perl use strict; use warnings; BEGIN { push(@INC, ".."); }; use Inline Python => 'DATA', DIRECTORY => '/usr/share/webmin/pykota/.Inline/'; Inline->init(); my $pykota_conf = new PykotaConfig('/etc/pykota/'); print "Admin mail for the AP400N: " . $pykota_conf->getAdminMail('AP400N') . "\n"; 1; __DATA__ __Python__ from pykota.config import PyKotaConfig as PykotaConfig