Recommendation for a small web framework like Perl's CGI::Applicationto run as CGI?

E

excord80

I need to make a small, relatively low-traffic site that users can
create accounts on and log into. Scripts must run as cgi (no
mod_python or FastCGI is available). Can anyone recommend a small and
simple web framework for Python, maybe similar to Perl's
CGI::Application?

Or would it just be better to roll my own?
 
T

Tim Chase

I need to make a small, relatively low-traffic site that users can
create accounts on and log into. Scripts must run as cgi (no
mod_python or FastCGI is available). Can anyone recommend a small and
simple web framework for Python, maybe similar to Perl's
CGI::Application?

Or would it just be better to roll my own?


What are you looking for in your framework? Python comes with
its own CGI module[1]. For the most basic of sites, this works
nicely.

However, if you want to be able to easily slide into a bigger
environment, I've been pleased with WebStack[2] for my
lightweight needs. It makes light work of transitioning from CGI
to other stacks such as mod_python, Twisted, WSGI, etc.

Backed with a simple sqlite DB, and some simple HTML/Python
templating, just using dict-expansion:

# template.html contains content like
# <p><b>field1</b> = %(field1)s</p>
template = file('template.html').read()
:
:
params = {
"field1": "value1",
"field2": "value2",
}
:
:
return template % params

Just set up the values in the params-dict, and use it to display
your template.

-tkc

[1]
http://docs.python.org/library/cgi.html

[2]
http://www.boddie.org.uk/python/WebStack.html
 
E

excord80

I need to make a small, relatively low-traffic site that users can
create accounts on and log into. Scripts must run as cgi (no
mod_python or FastCGI is available). Can anyone recommend a small and
simple web framework for Python, maybe similar to Perl's
CGI::Application?
Or would it just be better to roll my own?

What are you looking for in your framework?  Python comes with
its own CGI module[1].  For the most basic of sites, this works
nicely.

However, if you want to be able to easily slide into a bigger
environment, I've been pleased with WebStack[2] for my
lightweight needs.  [snip]

Thanks, Tim. I don't think WebStack is what I'm looking for, but will
investigate doing things by hand with the cgi module and using
Python's own built-in simple templating.
 
E

excord80

What are you looking for in your framework?

Well, let's see. I don't need a templating library, since -- as you
pointed out -- I can just use Python's own. I don't need a db
interface (can just make my own dbapi calls if needed). Don't need url
mapping (can just use mod_rewrite rules in my .htaccess to point at my
cgi scripts). Don't think I need any i80n. And I don't need an admin
interface. ... It would seem that I don't need a whole lot at the
moment.
 
J

James Mills

Well, let's see. I don't need a templating library, since -- as you
pointed out -- I can just use Python's own. I don't need a db
interface (can just make my own dbapi calls if needed). Don't need url
mapping (can just use mod_rewrite rules in my .htaccess to point at my
cgi scripts). Don't think I need any i80n. And I don't need an admin
interface. ... It would seem that I don't need a whole lot at the
moment.

One option is to configure Apache with mod_wsgi and just
use WSGI. Fairly simple really and much like CGI.

cheers
James
 
E

excord80

One option is to configure Apache with mod_wsgi and just
use WSGI. Fairly simple really and much like CGI.

This is a shared hosting arrangement, so I don't have the option of
adding an apache module. Also, if it's much like CGI, I don't see what
benefit it would provide over CGI in this situation.
 
G

Graham Dumpleton

One option is to configure Apache withmod_wsgiand just
use WSGI. Fairly simple really and much like CGI.

Worth highlighting with mod_wsgi is that you also don't have to have
everything inside of one WSGI application and can still use CGI like
approach of lots of WSGI script files. That is, you are relying on
Apache dispatching of URLs for file based resources and thus no Python
specific dispatcher needed, nor mod_rewrite rules.

Because each WSGI script files is given their own persistent sub
interpreter by default, with this approach you probably though want to
force them to all run in same sub interpreter to reduce memory usage.
This can be done using WSGIApplicationGroup directive.

For further information see:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive

Graham
 
B

Bruno Desthuilliers

excord80 a écrit :
I need to make a small, relatively low-traffic site that users can
create accounts on and log into. Scripts must run as cgi (no
mod_python or FastCGI is available). Can anyone recommend a small and
simple web framework for Python, maybe similar to Perl's
CGI::Application?

What about:
http://thraxil.org/code/cgi_app/

(yes, it is a port of CGI::Application, and FWIW it's mentionned on the
CGI::Application's wiki).

HTH
 
J

Jeroen Ruigrok van der Werven

-On [20090127 22:21] said:
I need to make a small, relatively low-traffic site that users can
create accounts on and log into. Scripts must run as cgi (no
mod_python or FastCGI is available). Can anyone recommend a small and
simple web framework for Python, maybe similar to Perl's
CGI::Application?

Werkzeug[1] should be in your line, I think.

[1] http://werkzeug.pocoo.org/
 
J

Jeroen Ruigrok van der Werven

-On [20090128 19:01] said:
Again, the solution must work for plain vanilla CGI. I don't have WSGI
available. But thank you.

It works for plain CGI. I myself use it for FCGI.
 
E

excord80

-On [20090128 19:01] said:
Again, the solution must work for plain vanilla CGI. I don't have WSGI
available. But thank you.

It works for plain CGI. I myself use it for FCGI.

Thanks, Jeroen. After looking at the Werkzeug "deploying" page, it
seems as though one is able to write a WSGI webapp and have it work
via CGI using something called wsgiref. Sounds good.

If that's correct, it would be great if there were a Werkzeug tutorial
on deploying it for use with CGI.

Will look into wsgiref and Werkzeug. Thanks!
 
F

Fred Pacquier

excord80 said:
Well, let's see. I don't need a templating library, since -- as you
pointed out -- I can just use Python's own. I don't need a db
interface (can just make my own dbapi calls if needed). Don't need url
mapping (can just use mod_rewrite rules in my .htaccess to point at my
cgi scripts). Don't think I need any i80n. And I don't need an admin
interface. ... It would seem that I don't need a whole lot at the
moment.

That would be something close to Karrigell...
 
E

excord80

That would be something close to Karrigell...

You know, I stumbled across Karrigell while looking around but was
initially uninterested because of what initially seems like a lack of
direction. That is, they tell you that you can use it any way you
like:

* python script
* K service
* html inside python
* python inside html
* cgi script

So, I wasn't sure what to make of that. However, perhaps it's a
strength... will have to look more into K.

Thanks.
 
J

Jeroen Ruigrok van der Werven

-On [20090128 20:36] said:
If that's correct, it would be great if there were a Werkzeug tutorial
on deploying it for use with CGI.

There are some real life frontends for CGI, FCGI and WSGI in Zine[1]. Look
in the servers directory in the repository.

I'll double check the documentation and expand where necessary.

[1] http://zine.pocoo.org/
 
B

Bruno Desthuilliers

excord80 a écrit :
Nice find. Thank you. Interesting project. It seems to be only one
fairly short file (perhaps that's all it takes),

It is. And given the intended context (CGI...), it's a GoodThing !-)
and its most recent
release was in 2004. No mailing list.

Nope. But does it need new release or a mailing list ? As you say, it's
just a pretty simple module. The point is that you are very likely to
fork it for your own needs anyway - so see it as a good starting point
for a simple lightweight CGI/mod_python (and why not WSGI) framework.
 
J

J Kenneth King

excord80 said:
I need to make a small, relatively low-traffic site that users can
create accounts on and log into. Scripts must run as cgi (no
mod_python or FastCGI is available). Can anyone recommend a small and
simple web framework for Python, maybe similar to Perl's
CGI::Application?

Or would it just be better to roll my own?

web.py

pretty simple. lots of deployment options.

ends up building into your own framework as your application grows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top