Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

A Piece of CherryPy for CGI Programmers

ScuttleMonkey posted more than 8 years ago | from the making-web-programming-easier-to-stomach dept.

Programming 193

An anonymous reader writes "IBM developerWorks is running an article outlining the strengths and offering some helpful advice on the Python framework 'CherryPy'. CherryPy uses the same concepts as CGI to bind a web server to a web application, but it improves performance and gains persistence across requests by handling all its requests within a single process."

cancel ×

193 comments

You mean... (5, Insightful)

nxtw (866177) | more than 8 years ago | (#13368835)

it runs a web application in a signle process, like ASP, ASP.NET, and most likely other technologies have been doing for some time?

This is nothing special. Just another framework that doesn't really do anything unique at all...

Re:You mean... (1)

Haydn Fenton (752330) | more than 8 years ago | (#13368886)

Didn't anybody tell you? Things that aren't unique in any way at all are totally in these days. Really, hop on the bandwagon and get rich from a piece of shit like the rest of the world.

Python GUI kit (1)

Commander Trollco (791924) | more than 8 years ago | (#13369097)

What is more interesting,
the Python GUI toolkit is gaining more acceptance
(if that is the right word). Will this mean more
options for open-source developers? So far it is
available as an experimental alpha, no word on
licencing schema when and if it is officially
released.

Re:Python GUI kit (1, Funny)

Anonymous Coward | more than 8 years ago | (#13369587)

Open Source developers need more options. Hopefully, with a Python GUI toolkit, we can see hundreds of incomplete, half-assed mp3 players written in python, to compete with the hundreds of incomplete, half-assed mp3 players written in perl.

Hoo-ray for options!

Re:You mean... (1)

Profane MuthaFucka (574406) | more than 8 years ago | (#13369127)

Wow, I've been having a rough time inventing something completely derivative and unoriginal to get rich off of. I must really suck.

Re:You mean... (2, Insightful)

Jerf (17166) | more than 8 years ago | (#13368889)

With the staggering number of frameworks available, "unique" is an awfully high bar. I'm not sure a standard that eliminates all frameworks from consideration is a valuable one.

Re:You mean... (1)

Mishra100 (841814) | more than 8 years ago | (#13368897)

That in untrue. This doesn't have to deal with ASP. This deals with CGI. You should be able to pipe CGI to this so that it would run faster, as we all know CGI is fairly slow.

Re:You mean... (0)

Anonymous Coward | more than 8 years ago | (#13368923)

I think the point is that this doesn't really do anything new, so it's not a big deal.

Re:You mean... (2, Insightful)

spectral (158121) | more than 8 years ago | (#13368943)

You mean like.. fastcgi? and then you aren't tied to your language?

Re:You mean... (0)

Anonymous Coward | more than 8 years ago | (#13369268)

true.dat

I use fastcgi with perl all the time. I love it, makes my apps very fast. Apache 2.0's "fcgi" module (fastcgi server component, but better maintained) works nicely almost out of the box.

Re:You mean... (1)

AstroDrabb (534369) | more than 8 years ago | (#13368953)

Umm, nxtw, you must have missed my memo! In the memo I told you to be "surprised" and "elated" about this "new" "technology"! I need to see you in my office, first thing Monday morning.

Oh, and until we speak, you should pretend to be excited about a "new" "technology" that is single threaded and susceptible to the whole process crashing because the _one_ thread it uses dies.

Re:You mean... (0, Flamebait)

Saeed al-Sahaf (665390) | more than 8 years ago | (#13368968)

Yes but it's a Python framework. PYTHON. That alone makes it HOT!

Re:You mean... (-1, Flamebait)

wealthychef (584778) | more than 8 years ago | (#13369640)

Damn, who modded parent down as flamebait? Dork! It was a joke! Sheesh. Get a sense of humor.

CGI's my cherry pie (3, Funny)

computerjunkie (128344) | more than 8 years ago | (#13369003)

CGI's my cherry pie.. A cool drink of water...

Re:CGI's my cherry pie (1)

Conspiracy_Of_Doves (236787) | more than 8 years ago | (#13369525)

Ok kids, who saw that one coming?

Re:You mean... (2, Insightful)

damiangerous (218679) | more than 8 years ago | (#13369073)

At no point in the article does this claim to be "unique" in any way. Quite the opposite, in fact. It acknowledges that there has been no shortage of these frameworks. The only way in which it's "unique" is that its Python. Basically, it exists simply so that people who know and enjoy Python can stick with it.

Re:You mean... (1, Interesting)

Anonymous Coward | more than 8 years ago | (#13369790)

The problem is, that every python web framework insists on creating it's own webserver, by which they mean call http.create which instantiates a very simple text processing daemon built into the language using simple sockets, which are also built into the language.

Re:You mean... (1)

DavidD_CA (750156) | more than 8 years ago | (#13369076)

... but it's got a neat name!!

Re:You mean... (1)

Saeed al-Sahaf (665390) | more than 8 years ago | (#13369164)

... but it's got a neat name!!

Reminds me too much about CherryOS... Not good.

Re:You mean... (1)

quanticle (843097) | more than 8 years ago | (#13369309)

Then perhaps they should have named it to be ApplePy. That way, all the patriotic programmers can claim that their programs use ApplePy to get work done, rather than plain ol' CGI, which everybody knows is just for the terrorists.

Re:You mean... (1, Informative)

Anonymous Coward | more than 8 years ago | (#13369111)

Wow, tough crowd. Maybe Django does the trick for you? It does some unique stuff, and is python: http://www.djangoproject.com/ [djangoproject.com]

Re:You mean... (5, Interesting)

jma05 (897351) | more than 8 years ago | (#13369298)

CherryPy is nothing like ASP, ASP.NET. The script you write is EVERYTHING. You don't need a web server like you do in ASP/ASP.NET. It is the web server with your code in it. I have been using CherryPy for a while. What is nice about it is that for simple things, it justs steps out of the way. There is very little framework code in my apps and they just feel like console programs.

Re:You mean... (0)

Anonymous Coward | more than 8 years ago | (#13369335)

Kind of a big deal. At work we only have the Windblows development tools and Python. And now I'll have the option of using this Python tool in order to help pull the dirty Windows needle out of the arm of the addicted, locked-in company. And maybe even run some other servers instead of those x86 only boxes Windblows runs on. Good way to use some older, non-x86 equipment lying around.

Obligatory (4, Funny)

Limburgher (523006) | more than 8 years ago | (#13368837)

units.smile.face.width = "Miles"; smile.face.width = "10";

Re:Obligatory (2, Insightful)

Anonymous Coward | more than 8 years ago | (#13368876)

I hate to be anal about a joke, even if it doesn't really qualify as one, but shouldn't that be more like this?

face.smile.width.units = "Miles"
face.smile.width = 10

Re:Obligatory (0)

Anonymous Coward | more than 8 years ago | (#13369297)

that's why I hate python. I like my curley braces and semi colons. The only ones allowed to do that should be bash, ksh, or any sh.

Re:Obligatory (1)

strider44 (650833) | more than 8 years ago | (#13369408)

doesn't really matter - they're both equivalent...

Re:Obligatory (-1, Troll)

masklinn (823351) | more than 8 years ago | (#13369811)

... in javascript

Re:Obligatory (1)

SilicaiMan (856076) | more than 8 years ago | (#13369485)

You're missing a few leading spaces.

/me ducks and runs for cover ...

Careful now. (1)

Whizzmo2 (654390) | more than 8 years ago | (#13369755)

"Please step out of the booth, sir. We have a warrant [lyricsdepot.com] for your dessert."

Gotta do it. (-1, Troll)

Anonymous Coward | more than 8 years ago | (#13368839)

FIRST PYST!!!!!

One... (-1)

Anonymous Coward | more than 8 years ago | (#13368877)

million pilgrims attend open-air mass with Pope
http://en.wikinews.org/wiki/One_million_pilgrims_a ttend_open-air_mass_with_Pope [wikinews.org]

Re:One... (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#13369020)

Wikinews is shit. Just recycles and rewords newswires, resulting in second or third-hand accounts. The articles don't go in-depth enough, a few hundred words at the most. The quality of writing is poor and inarticulate. Any attempt at "original reporting" is dismissed (I tried, got fed up of having my work reverted). Technical limitations result in difficulties with titles, and so on...

Re:One... (1)

larry bagina (561269) | more than 8 years ago | (#13369604)

sounds familiar...

PyDie (2, Funny)

Anonymous Coward | more than 8 years ago | (#13368882)

OK, enough with the silly Py names. PyCrust, PyShell, and now CherryPy, sheesh.

Re:PyDie (-1, Offtopic)

mnemonic_ (164550) | more than 8 years ago | (#13369098)

Speaking of pie, can anyone recommend some good recipes? I haven't had a decent slice in ages.

So, we now have (3, Insightful)

TDScott (260197) | more than 8 years ago | (#13368888)

Regular CGI, mod_perl, mod_python, the newcomer Ruby on Rails, and now CherryPy. Granted, some webhosts [dreamhost.com] handle the first four (even Rails) without any problems, but how many do we really need?

I suppose the answer is "as many as it takes" — whatever's easiest for some users will be utterly impenetrable to others, and it's good to have choice. But at what point does it start to become a burden to keep up with all these — either for programmers looking to keep their CVs up to date, or hosts wanting to stay current?

Whoops - sorry, to head off any criticism: (4, Informative)

TDScott (260197) | more than 8 years ago | (#13368898)

that's a referral link in the parent post. To be honest, I'd recommend them anyway, but it's probably best to disclose it.

Umm.. (3, Informative)

Anonymous Coward | more than 8 years ago | (#13368891)

FastCGI anyone?

I have been doing that with python and perl for years. I can even run the CGI on multiple different hosts with one webserver.

Re:Umm.. (2, Interesting)

dotgain (630123) | more than 8 years ago | (#13369486)

Sure, FastCGI is great, I agree. But, even after all these years "Fast" and "Python" still aren't allowed to be used in the same sentence, hence CherryPy. Mark me Troll, that's fine, but please tell me: Am I the only one that thinks CGI in python is insane because it's the all round slowest-to-run programming language about? Sure it's nice to write and easier to read than most, but for any program you end up running 100 times more often than you write it, choose somthing else.

Can anybody show me that Python is a realistic contender for CGI - or for that matter - any programming? I used to subject myself to a Linux distribution called Gentoo [gentoo.org] whose package mismanagement system, Portage, is mostly if not entirely done in Python. I found that for compiles of many small packages, we spent about as many CPU seconds on 'emerge' itself than we did building. Running 'emerge' on something old and spluttery like a sparc32 is just not the done thing. You've got probably 30 seconds before you've got any indication that the program has validated your input and started processing at which point you find something else to do.

Give me a reason to use this (3, Interesting)

wilsoniya (902930) | more than 8 years ago | (#13368906)

I'm not a py programmer at all, but seeing as numerous single-process dynamic web platforms exist (PHP, JSP/Servlets), whats w/ all the hype? Maybe ppl are just happy to be able to use python for web apps?

-m

Re:Give me a reason to use this (3, Interesting)

Poromenos1 (830658) | more than 8 years ago | (#13368921)

Probably... Personally I love Python, and one of the things I love is that it's still being developed. You can actually suggest something and see it implemented in the language. You can probably do that in many more, but all the others I know have been standardised. Plus it has all the other great stuff which makes it my first choice for anything.

Re:Give me a reason to use this (4, Interesting)

Nasarius (593729) | more than 8 years ago | (#13368947)

There are already efficient ways of using Python for web apps. FastCGI and mod_python, for example. I'd like to see benchmarks for this new one.

Re:Give me a reason to use this (0)

Anonymous Coward | more than 8 years ago | (#13369085)

CherryPy can use mod_python, FastCGI - anything WSGI can do.

Re:Give me a reason to use this (1)

utnow (808790) | more than 8 years ago | (#13368951)

people like to use what they're comfortable with. i started programming with basic, so ASP was my first real 'happy language' for the web. of course when i discovered PHP that all changed but you get the picture. My mom used to do alot of python programming back in her day so I'm sure this would be good news for her.

What being in a single process really means (5, Informative)

MostlyHarmless (75501) | more than 8 years ago | (#13369013)

In the first few posts, I've seen a lot of relatively lacking-in-clue replies asking how CherryPy is different from ASP.NET, mod_python, FastCGI, etc. With most Apache-based web platforms, one process will handle many requests, but you cannot guarantee that every request will be handled by the same process: by default, apache starts multiple (possibly multi-threaded) servers, and creates and destroys them as necessary.

CherryPy, on the other hand, runs every request from the same process by using a thread pool instead of a process pool. This means that any global variables you change will be visible to any request. In many cases (keeping in mind memory restraints), you can share items in memory that would otherwise have to go through the database, which can help performance and make keeping track of state easier. Of course, multithreaded data sharing places its own demand on the programmer: the Python core is inherently thread-safe, but no programming language can protect you from race conditions and the like.

I've played around a little bit with CherryPy, and writing in it definitely feels Pythonic. It may still need some more development before it is fully mature, but it's something to at least keep an eye on.

(On a side note: I don't know how the IIS/ASP.NET process model works. It does let you store data across an application, but you are limited to a single Application hashtable, probably to be orthogonal to the Session and Viewstate objects and to reduce the likelihood that a programmer not experienced with concurrency would shoot him/herself in the foot.)

Re:What being in a single process really means (2, Informative)

nxtw (866177) | more than 8 years ago | (#13369087)

In the first few posts, I've seen a lot of relatively lacking-in-clue replies asking how CherryPy is different from ASP.NET, mod_python, FastCGI, etc. With most Apache-based web platforms, one process will handle many requests, but you cannot guarantee that every request will be handled by the same process: by default, apache starts multiple (possibly multi-threaded) servers, and creates and destroys them as necessary.

ASP.NET uses a single process for each application. Every request is processed by the same process, both in Mono's implementation with mod_mono and on the IIS implementation. This is, as I said, nothing special, uncommon, or unique. My post was definitely not lacking in clue.

CherryPy, on the other hand, runs every request from the same process by using a thread pool instead of a process pool. This means that any global variables you change will be visible to any request. In many cases (keeping in mind memory restraints), you can share items in memory that would otherwise have to go through the database, which can help performance and make keeping track of state easier. Of course, multithreaded data sharing places its own demand on the programmer: the Python core is inherently thread-safe, but no programming language can protect you from race conditions and the like.

ASP.NET runs every request for an application within the same worker process. Static classes can be accessed from all threads throughout the application's lifetime (until it is stopped).

(On a side note: I don't know how the IIS/ASP.NET process model works.

Proving that you are indeed "lacking-in-clue"...

It does let you store data across an application, but you are limited to a single Application hashtable

This is not the only way to store data across an application in ASP.NET. Static classes, variables, etc. stick around for the entire time the application is running. ASP.NET also has its Cache object, which works like Application except Cached objects will expire at a programmer-defined time or after a programmer-defined timespan. The Cache object allows for callbacks for when an object is removed from the Cache, and cache dependencies.

I believe that ASP.NET's page and partial page caching uses this.

That's the same thing as a servlet (1, Redundant)

irritating environme (529534) | more than 8 years ago | (#13369606)

Welcome to 1998.

Re:What being in a single process really means (1)

turnerjh (271) | more than 8 years ago | (#13369750)

Yes, being in the same process is very helpful! That is, until you have to scale your website. Uh oh, you have maxed out your server. Okay, you buy a bigger server. Time passes. Congratulations, your site is very successful and you max it out! Too bad your now-popular app is riddled with assumptions that come from all requests being inside the same process.

Learn from the big guns of websites -- scale horizontally. Frontend proxies load balancing across multiple backend servers. Redundancy and scalability. Definitely don't assume all of a user's requests will come to the same server. For goodness sake, though, don't start out fundamentally limited in your potential scale.

People are looking at this the wrong way (5, Interesting)

sean23007 (143364) | more than 8 years ago | (#13369015)

I think people are looking at this the wrong way. I see a lot of posts saying "who cares? ASP is already like that!" or "You're supposed to have it in a single process anyway!"

What makes this cooler is that Python functions are exposed in the URL. Read through that IBM tutorial. It's fairly interesting. Put a function called hello() in your CherryPy application, and the return value of that function is displayed in your web browser when you visit http://address/hello [address]

I don't know about you, but I think that's pretty cool. You could definitely do some interesting stuff with this, and I can see it saving a lot of time in the code-writing phase. And once you get your head wrapped around that concept pretty well, the design phase would probably get a lot shorter too. (Not to mention how much easier it would then become to add new features to the application.)

This is interesting for two reasons: Python frameworks are now catching up to things like ASP and PHP, but are doing some crucial things differently that might make it much easier/more powerful. I might start using this instead of PHP for small web apps that just need to talk to a database, and see how it goes from there.

Re:People are looking at this the wrong way (1, Insightful)

melted (227442) | more than 8 years ago | (#13369092)

>> Python frameworks are now catching up to things like ASP and PHP

That's wrong on so many levels. For starters, ASP (assuming you mean ASP.NET) is lightyears ahead of anything python simply because it gets compiled into machine code before it's executed and runs "closer to the iron" (and therefore blows the doors off anything interpreted). I could name five dozen other reasons why ASP.NET and similar Java based frameworks are better, but I don't want to waste time. There's google, you can find it yourself.

Second, what this particular Python framework is really catching up with is Ruby on Rails. And quite frankly, anyone who likes the sort of thing that RoR implements should just use RoR, not imitations.

Re:People are looking at this the wrong way (0)

Anonymous Coward | more than 8 years ago | (#13369125)

Tcl httpd has been doing this for *ages*... Sheesh - you python people think that everything you do is so new and cool... Sheesh...

Oooh look! Hello World!

Re:People are looking at this the wrong way (0)

Anonymous Coward | more than 8 years ago | (#13369166)

>> Python frameworks are now catching up to things like ASP and PHP

That's wrong on so many levels

Also, PHP is definitely NOT something you want to "catch up to"...

People are looking at this the wrong way (3, Interesting)

darekana (205478) | more than 8 years ago | (#13369240)

Actually I think CherryPy and Zope have been around a while before Ruby on Rails. And speed wise Python kicks Ruby's ass [debian.org] for now.

And actually I don't know of any java frameworks that don't require tons o' xml flinging to get up and running. Please feel free to enlighten me.

Re:People are looking at this the wrong way (1)

jarich (733129) | more than 8 years ago | (#13369428)

Actually I think CherryPy and Zope have been around a while before Ruby on Rails

You are correct, but neither have the ease of use and the speed of application development that Rails has. Given this development however, I'd be surprised if someone isn't hammering out a Rails-esque framework for Python as we speak! :)

Re:People are looking at this the wrong way (2, Informative)

ziplux (261840) | more than 8 years ago | (#13369460)

Someone is, and it's called Subway: http://subway.python-hosting.com/ [python-hosting.com]

Re:People are looking at this the wrong way (4, Insightful)

jma05 (897351) | more than 8 years ago | (#13369718)

For crying out loud, please read the article/manual. Zope and CherryPy have NOTHING in common with Rails other than they are web app frameworks using dynamic languages. They are all different frameworks addressing different needs. Zope is very complex because it addresses a very complex problem and provides a comprehensive framework. CherryPy is similar to Rails in that functions become URLs seemlessly (no messy xml, special output calls etc) but other than that it is much simpler than Rails. It is an web application server and nothing more. It does not have a templating system, no ORM, no database abstraction -- NOTHING. All it does is manage your code for the web. You choose whatever templating system you want (I chose Cheetah), whatever ORM you want (I chose SQLObject), and whatever DB access module (I chose MySQLdb). It is a simple tool that imposes no restrictions and plays well with other tools. Development in CherryPy is similar to development with mod_python although the infrastructure is completly different. Sometimes CherryPy is easier to develop with than mod_python. STOP COMPARING EVERYTHING WITH RAILS BECAUSE THAT IS ALL YOU HEAR IN THE NEWS.

Re:People are looking at this the wrong way (0)

Anonymous Coward | more than 8 years ago | (#13369438)

And actually I don't know of any java frameworks that don't require tons o' xml flinging to get up and running.

Many of them seem to be moving to using annotations (requiring Java 1.5) instead, but that process is taking a while.

Re:People are looking at this the wrong way (1)

chez69 (135760) | more than 8 years ago | (#13369457)

personally, I like struts a lot. struts isn't that bad to get running. I work with folks that can barely spell java and they have no problems with it.

I do agree, tons of XML files are a pain in the ass.

Re:People are looking at this the wrong way (1)

masklinn (823351) | more than 8 years ago | (#13369829)

Struts is a piece of shit and probably the worst java framework available...

Oh, and if you run it on top of Tomcat you're doomed...

Re:People are looking at this the wrong way (2, Informative)

civilizedINTENSITY (45686) | more than 8 years ago | (#13369288)

"is lightyears ahead of anything python simply because it gets compiled into machine code"

Actually,
.NET introduced a new programming language environment that compiles all source code into an intermediate language. .NET languages are compiled into the Microsoft Intermediate Language (MSIL), which is executed by the Common Language Runtime (CLR) software in the Windows computer. The MSIL is similar to Java's bytecode, except that whereas Java is one language, .NET supports multiple programming languages...
Now that is also not quite true, because people have written various JVM bytecode compilers for their languages, or implemented their languages in Java. (See Jython [jython.org] for the latter, or The Tcl/Java Project [sourceforge.net] , or The scheme package [koala.ilog.fr] for Java based scheme. lists some 200 languages that have been ported to the JVM.) [robert-tolksdorf.de]

Re:People are looking at this the wrong way (-1, Troll)

Anonymous Coward | more than 8 years ago | (#13369348)

o for fucks sake. ur a real asp.cock..

u fucking faggot. who cares if its compiled if it still sucks. go shove your rails up ur ass.

Re:People are looking at this the wrong way (1)

jma05 (897351) | more than 8 years ago | (#13369776)

First, Dynamic languages are light years ahead of mainstream static .NET languages supported in the IDE with ASP.NET (I said, mainstream because .NET is getting good dynamic languages and other static languages like Boo are much more expressive than say C# but are not supported in VS [although in SharpDevelop]). I choose a Python framework when most of my logic is likely to be problem oriented rather than framework oriented.

I choose .NET when it has components that I can directly use that otherwise would require me to implement and when IDE is actually likely to make me productive. I have in the past but recently that has not been the case.

Python/Ruby/Perl development model has distinct advantages that current .NET dev models don't currently cater. Likewise, .NET offers some effective solutions that are more painful with other methods.

"and therefore blows the doors off anything interpreted"

Python is compiled to byte code just like .NET, not interpreted. As for JIT, most people simply don't see the need (see below) but are available (Psycho).

Python based solutions (I said solutions, not code) rarely run slower than equivalent .NET counterparts because most performance critical code runs in native code anyway and not Python and especially so in case of web based applications. I can't imagine what performace critical code you could possibly be writing in a web app. Fetching millions of records?, your DB library implemented in C does that; heavy page load, your templating system needs to be optimal and so on.

"Second, what this particular Python framework is really catching up with is Ruby on Rails. And quite frankly, anyone who likes the sort of thing that RoR implements should just use RoR, not imitations."

That's a pure troll. You have no idea of what CherryPy does. CherryPy is not an imitation of RoR. It's been there before RoR. It does things very differently. I am not going to repeat the differences. Look at my other post in this discussion for that or BETTER, actually read the manual or article.

People are looking at security the wrong way (1, Insightful)

Anonymous Coward | more than 8 years ago | (#13369096)

"Put a function called hello() in your CherryPy application, and the return value of that function is displayed in your web browser when you visit http://address/hello [address] [address] "

And the security issue?

Re:People are looking at security the wrong way (1)

jma05 (897351) | more than 8 years ago | (#13369675)

"And the security issue?" RTM. No security issue. You get to specify which functions are exposed. They are not exposed by default. Either use Python decorators to annote public functions of write a simple function to expose by naming convention. Python's dynamism makes this a breeze.

Re:People are looking at this the wrong way (3, Informative)

Beek (10414) | more than 8 years ago | (#13369349)

> Put a function called hello() in your CherryPy application, and the return value of
> that function is displayed in your web browser when you visit http://address/hello [address]

Rails and Struts already have this feature.

(Of course, for Struts you need a some XML for every class you want to act this way.)

Re:People are looking at this the wrong way (1, Informative)

Anonymous Coward | more than 8 years ago | (#13369546)

as does perl's catalyst [perl.org] .

rm -Rf (1)

PhYrE2k2 (806396) | more than 8 years ago | (#13369411)

I can see it now.

http://www.site.com/rmdir [site.com]
http://www.site.com/mke2fs?/dev/sda [site.com]
http://www.site.com/kill [site.com] `pidof httpd`

Re:rm -Rf (2, Informative)

sean23007 (143364) | more than 8 years ago | (#13369567)

I'm assuming you didn't read the article, because it explains that CherryPy doesn't just call whatever function is passed in the URL. The programmer has to explicitly expose his functions to the CherryPy server instance. Otherwise, they won't be called. So unless for some reason you @cpg.expose rmdir or kill or any other system function (which you would obviously never do) this isn't an issue.

Ahhh, injection attacks (1)

irritating environme (529534) | more than 8 years ago | (#13369641)

Great, so it's vulnerable to mass injection attacks. You COULD do this in Java Reflection. But you wouldn't. Ever.

Cool! (4, Interesting)

smoondog (85133) | more than 8 years ago | (#13369063)

Python is a great language, but my worry is about security. I would think that given the previously mentioned cool features, this app would have more security worries than your average all-in-the-same-process cgi extenders.

Its all in the marketing .... (1, Interesting)

Anonymous Coward | more than 8 years ago | (#13369162)

CherryPy implements some useful ideas, but no more so than various other Python frameworks available out there. There are after all only so many ways of mapping URLs into a Python based framework, and there are currently a lot of Python based web frameworks, thus a lot of duplication.

It is sad to say, but at the moment the war as to which is perceived as being the better Python framework for web applications is being won more on the marketing side than on the particular technical merits and quality of implementation.

There are some people out there who are developing some really quite interesting stuff based on inovative ideas and who are producing good quality code as well, but in many cases, although they may result in a better experience as far as developing a web application, because they don't have the associated marketing that some projects have, they get passed over and the projects never get developed that extra step to turn them into something awesome.

The ultimate in hype for Python web frameworks of late has been Django. It has been getting a huge amount of mind share by comparing itself to Ruby on Rails. The last time I looked they still hadn't actually made an official release.

In summary, if you want to build a successful Open Source project, don't start by writing code, do what any commercial business does and ratchet up the hype through marketing and promise the world. Do that and you will be almost certain to get lots of people to help you with the code once you do start. :-) :-) :-)

Nevow (4, Informative)

kevin_conaway (585204) | more than 8 years ago | (#13369173)

I'll got ahead and put in a plug for Nevow [nevow.com] here, another web framework that is based on the EXCELLENT Twisted [twistedmatrix.com] framework.

If you're doing any sort of network programming in Python, you need to look at Twisted.

Uhh.... Single-process? (0)

Anonymous Coward | more than 8 years ago | (#13369180)

So, in other words, it performs poorly on multi-processor machines? Or, is it threaded? (I don't know if threaded would count as single-process. Sure it counts in terms of terminology, but in the eyes of the kernel threads are just another form of process.)

And it shares resources with other instances of itself and other webapps. For something that gets used a lot (say, Slashdot) I'd imagine it'd run out of file descriptors and/or memory pretty quickly.

" All it does is..." (5, Interesting)

LionKimbro (200000) | more than 8 years ago | (#13369187)

It says "All it does is connect the Web server to your Python code with as little fuss as possible. It doesn't make decisions about what other tools to use, ..."

And then in the very next paragraph, it says: "Instead of relying on Apache or another Web server, CherryPy runs its own small Python-based Web server."

No, no, no!

I love CherryPy as a way of routing requests to Python objects and functions. Rock on!

But look, I'm running like 20 wiki [taoriver.net] and 5 custom web apps and a few WordPress [wordpress.org] installations on my server. [taoriver.net]

And they are all plugged into Apache.

So, actually, in fact, CherryPy has now made some decisions about what tools I'm supposed to use.

Sure, I can forward requests from Apache to the CherryPy server, but that is yet another hassle, it is yet another thing to support and maintain and think about.

I wish instead that the CherryPy dev's had made it so there were multiple adapters to the CherryPy system.

All that said:

CherryPy is my favorite system for doing web apps in Python. I've used it, I've loved it, it's great. It does make programming WebApps "fun," which is perverse. So, it's succeeded.

But I strongly dislike how I have to do this funny Apache business to get it to run on port 80, or I have to give people weird 8080 addresses, like you saw in the article.

Another thing I dislike, is that it's kind of tricky to get it to do XML-RPC, in my experience. (Then again, that was 3 months ago. Perhaps things have changed now.)

(I just use AutoXmlRpcServer [python.org] or AutoXmlRpcCgi [python.org] for when it's XML-RPC alone, without a web side along with it.)

But again: CherryPy is my favorite, when there is no XML-RPC aspect, and when I don't mind the weird config stuff I have to do to get it to cooperate with Apache.

Wow, dude. Chill. (3, Insightful)

jbellis (142590) | more than 8 years ago | (#13369337)

If you're "running like 20 wiki and 5 custom web apps and a few WordPress installations" on your server then you shouldn't be intimidated by the 2 or 3 lines it takes to forward requests to the CherryPy server.

Get a grip.

Re:Wow, dude. Chill. (2, Interesting)

LionKimbro (200000) | more than 8 years ago | (#13369756)

It's not just the 2 or 3 lines in the Apache server.

It's:

  • The 2 or 3 lines in the Apache server.
  • Learning where in the Apache documentation those 2 or 3 lines are, and familiarizing myself with them.
  • Debugging those 2 or 3 lines, fiddling with Apache a bunch.
  • Figuring out the details of where the CherryPy server is going to run, with what priviledges, with what permissions on what directories.
  • Figuring out how to configure the CherryPy server.
  • Figuring out how to make the CherryPy server automatically start when the computer boots up.
  • Making the changes so that it autostarts when the computer boots.
  • And then testing that it autostarts when the computer reboots, by actually rebooting it.


I just plain don't like any of that stuff. None of it.

I'm not a sysadmin; I'm lucky to have cobbled together my 20 wiki, 5 custom web apps, and a few WordPress installs. I dread upgrading my Wordpress blogs, one of which isn't even working right now, and has been custom hacked. Something about not being able to connect with the MySQL db for some reason, I don't know. I don't even care at this point. I dislike diddling with stuff.

Gimme as few pieces as possible. Don't make me think about security, don't make me make things automatically start at boot time, plug into my existing framework, yadda yadda yadda.

Gimme gimme gimmy!

Re:" All it does is..." (2, Funny)

Anonymous Coward | more than 8 years ago | (#13369454)

Perhaps.

You could put more than one thought.

On each line.

Quixote does XMLRPC easier... (1, Informative)

Anonymous Coward | more than 8 years ago | (#13369535)

As an alternative, Quixote http://www.mems-exchange.org/software/ [mems-exchange.org] has a slightly different flavor to exposing Python objects via the url, probably a little more secure out of the box (including cross site scripting protection) and does XMLRPC in a straightforward manner.

Seems only useful if you already do Python CGI. (2, Insightful)

mcc (14761) | more than 8 years ago | (#13369206)

All it does is connect the Web server to your Python code with as little fuss as possible. It doesn't make decisions about what other tools to use, so you're free to pick a templating system, database mapper, or other tool on its own terms.

This is kind of a problem though because I actually need a templating system, database mapper, and some other tools. I have some such tools in Perl, but I obviously can't take these with me into Python.

So I am wondering. Were one to use CherryPy, what would be logical tools to build on top of it with? If I need to be able to take objects and convert them into lines in a database or HTML for display or HTML forms for editing or whatnot, what would be the logical things to plug in on top of CherryPy to provide this?

Re:Seems only useful if you already do Python CGI. (5, Informative)

justrob (445616) | more than 8 years ago | (#13369236)

Using SQLObject is very popular with CherryPy users. CherryPy works with just about any templating system out there. This also makes it very easy to port from other Python web frameworks because you can use your existing templates.
  Subway [python-hosting.com] was created to use CherryPy, SQLObject and Cheetah templates in a very Ruby on Rails-like way, so you don't have to go through the 10 zillion decisions of what to use with CherryPy and tells you "what to do and where to put it".

Other python based web interfaces ? BEST ? (1)

vortek (890535) | more than 8 years ago | (#13369212)

What is the best or most stable method then?
I see this program is unstable and only supports ssh1 sort of. What is the most stable method of using a web interface to connect to a shell.
Lets say like using www to ssh or even some thing like cgi.irc wich uses a web interface to a shell then irc's.

Gee, it sounds just like... (3, Informative)

mengel (13619) | more than 8 years ago | (#13369246)

... FastCGI which has had a several [sourceforge.net] python [lysator.liu.se] modules [suxers.de] for about 10 years...

But of course, if IBM says it's new, well it must be ;-)

Okay, I checked, and I exagerrated a little bit, the earliest CVS version on mod_fastcgi.c is:

Revision 1.1 / (download) - annotate - [select for diffs] , Tue Sep 16 15:38:22 1997 UTC (7 years, 11 months ago) by stanleyg

Re:Gee, it sounds just like... (1, Informative)

Anonymous Coward | more than 8 years ago | (#13369270)

CherryPy can use FastCGI or mod_python or anything WSGI supports. Its not a replacement for FastCGI.

Obligatory Quip (1)

Dark Coder (66759) | more than 8 years ago | (#13369302)

Easy as pie?

not so easy (1)

subtropolis (748348) | more than 8 years ago | (#13369735)

it's barely still virgin

django! (/. missed the hype train) (5, Interesting)

brendano (457446) | more than 8 years ago | (#13369313)

The big thing in python web programming right now is the introduction of Django [djangoproject.com] , a mature RAD framework that shares lots of features with Rails. It's got a lot going for it; it'll be interesting to see how things turn out.

I find CherryPy's URL traversal scheme a bit clunky -- since you connect up objects to each other via attributes, you can't see the hierarchy of your site. At least with PHP you can use "ls" to discover what your URL space looks like. Django uses a really neat scheme that binds a table of named regular expressions to callable handlers, e.g.

(r'^polls/(?P<poll_id>\d+)/$', 'myproject.apps.polls.views.polls.detail')

and the handler is declared as

def detail(request, poll_id)
...

...so that requesting /polls/13/ maps to calling detail(request, 13). Here's more about it... [djangoproject.com]

Re:django! (/. missed the hype train) (1)

lukelele (889635) | more than 8 years ago | (#13369601)

heh. no, i think you missed the /. hype train. Posted Aug 02 [slashdot.org]

hmm, maybe .. (1)

josepha48 (13953) | more than 8 years ago | (#13369399)

.. I need to read more.. but this sounds like apache and tomcat interoperation.. tomcat being one process to handle the jsp requests...

Why not just embed the python interpreter in an apache module ....

Re:hmm, maybe .. (1)

jma05 (897351) | more than 8 years ago | (#13369793)

Already been done. It's called mod_python.

Bah, Scripting languages (1, Troll)

Jessta (666101) | more than 8 years ago | (#13369504)

There are too many scripting languages...actually there are too many interpreters for scripting languages.
Except for the syntax differences, what is the difference between ruby,perl,php and python?
Seeing as they are so similar why should I have to install four different interpreters and why should applications have to be ported between the languages?
Seems like a large waste of time.
I'm all for lots of versions of the same sort of tool as long as they are compatible.

This is some thing microsoft got right. .NET is really great in that way.
Many languages, one interpreter.

- Jessta

Re:Bah, Scripting languages (1)

Hoxworth (570683) | more than 8 years ago | (#13369575)

"Many languages, one interpreter."

Right, but that happens to be one very large and bloated interpreter for a bunch of languages that only work on proprietary systems with proprietary applications.

Agile developers know that flexibility can be one of his or her greatest assets. Who cares if a few more frameworks need to be installed, as long as the final product is actually useful and can be installed on any Windows or un*x environment (and in some cases, such as certain ruby on rails developments, in much less time)?

Re:Bah, Scripting languages (1)

Jack9 (11421) | more than 8 years ago | (#13369759)

>>Except for the syntax differences, what is the difference between ruby,perl,php and python?

Your questions seem nonsensical, excepting this one. I'm just talking off the cuff here, but if someone asked me this aloud I might say...

Perl was initially for sorting, reading, rearranging text. It was expanded, logically into being an apache module. Apache serves plaintext HTML documents. Perl expanded its feature set in every direction...a proverbial hammer for any kind of problem. Other languages suffer from trying to emulate Perl...PHP/Python

PHP was initially hacked together from Perl scripts, for RAPID web development with an eye to performance (LAMP) for serving simple HTML pages utilizing simple queries. Every other part of the PHP feature set, has been tacked on (in spirit). (BTW, I am a PHP web-developer)

Python is an Object Oriented language experiment. An interpreted language that can be compiled. Based on the Java ideal without the "Everything is an Object", clearer syntax than Perl, and more consistency within the syntax (than Java).

Ruby is a Smalltalk revival. Object Oriented language based on the Java ideal. Everything is an object. Mutable syntax. Garbage collection. Lots of original features like being able to pass closures. I would use Ruby if there was more support. .NET has an ungodly footprint on both the client and server. It's Microsoft only. .NET is terrible in design. Works good...MS says.

Re:Bah, Scripting languages (1)

Jessta (666101) | more than 8 years ago | (#13369806)

I agree that .NET is a bad implementation of a good idea.
But it's still a good idea.
No matter what language a program is written in, everything comes back to cpu instructions.
Which are the same.

I see no reason why there should be such large incompatiblities between languages.

It seems crazy to translate a program to a different language just so it can be incorporated in to a program of the language of my choice.

Re:Bah, Scripting languages (1)

masklinn (823351) | more than 8 years ago | (#13369848)

Except for the syntax differences, what is the difference between ruby,perl,php and python?

Features, object orientation, philopophy (you don't code in Ruby or Python the way you'd code in Perl, and you don't code in PHP at all if you can avoid it)

For windows users... (3, Funny)

Jeffus (783068) | more than 8 years ago | (#13369518)

...how about a piece of ApplePy?

Re:For windows users... (1)

lukelele (889635) | more than 8 years ago | (#13369622)

That would involve eating some HumblePy first. Too filling ;)
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...