[Grok-dev] Grok newbie - is it possible to call cgi prog without Apache?
Martijn Faassen
faassen at startifact.com
Thu Nov 19 08:51:37 EST 2009
Hey,
Kathy Manwaring wrote:
> I want to use Grok for software I am developing and need to know whether
> the following is possible. I would prefer to use Grok standalone, rather
> than with Apache.
Apache is still one of the best ways to work with CGI, but I can imagine
it's annoying to have to develop stand-alone. You could perhaps
partition your application so you have difficult deployment scenarios,
one for development where you can skip the CGI.
Alternatively you could host the CGI script on some URL somewhere (using
Apache) and then use Python's "urllib2" to just load that URL from
within your Grok application. I'm not sure whether that's possible with
this particular CGI script.
> I need to check that a system and user is licensed when they access the
> home page. So I need to call a CGI program, as having the licensing
> process present in plain code seems a little dumb...
Why does it seem dumb? I mean, if it's possible to call some API to
check whether the system and user is licensed that'd be the easiest,
right? But I think I don't understand something.
> I tried putting the
> CGI into /static/ directory in my Grok area, but get a 404 error when
> accessing it (probably because static is intended for css, images etc).
Yes, static isn't going to process CGI. It's only meant to publish
static resources and not process anything.
> Is it possible to do this? If so, where does the CGI program live?
I don't have experience with this myself, so I'm only going to be able
to give you a pointer.
Grok (in more recent versions) uses Paste Deploy:
http://pythonpaste.org/deploy/
This includes a WSGI server and a way to use WSGI infrastructure. In
Grok, you'd modify various .ini templates that are in 'etc' and run
"bin/buildout" to install them into parts/etc/ to include WSGI middleware.
Tere are solutions to integrate CGI with WSGI. A quick google comes up
with this, though this looks positively ancient (2005):
http://blog.sysfs.net/archives/7-WSGI-application-wrapper-for-CGI-scripts.html
This looks more recent (Paste, which includes this, should already be
included when you install Grok, so you can just import it):
http://pythonpaste.org/modules/cgiapp.html
Regards,
Martijn
More information about the Grok-dev
mailing list