Slashdot Mirror


A Piece of CherryPy for CGI Programmers

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."

193 comments

  1. You mean... by nxtw · · Score: 5, Insightful
    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...

    1. Re:You mean... by Haydn+Fenton · · Score: 1

      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.

    2. Re:You mean... by Jerf · · Score: 2, Insightful

      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.

    3. Re:You mean... by Mishra100 · · Score: 1

      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.

    4. Re:You mean... by Anonymous Coward · · Score: 0

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

    5. Re:You mean... by spectral · · Score: 2, Insightful

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

    6. Re:You mean... by AstroDrabb · · Score: 1
      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.

      --
      If Tyranny and Oppression come to this land,
      it will be in the guise of fighting a foreign enemy. -James Madison
    7. Re:You mean... by Saeed+al-Sahaf · · Score: 0, Flamebait

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

      --
      "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    8. Re:You mean... by damiangerous · · Score: 2, Insightful

      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.

    9. Re:You mean... by DavidD_CA · · Score: 1

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

      --
      -David
    10. Re:You mean... by Anonymous Coward · · Score: 1, Informative

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

    11. Re:You mean... by Profane+MuthaFucka · · Score: 1

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

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    12. Re:You mean... by Saeed+al-Sahaf · · Score: 1
      ... but it's got a neat name!!

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

      --
      "Who are in control, they are not in control of anything - they don't even control themselves!" - Glen Beck
    13. Re:You mean... by Anonymous Coward · · Score: 0

      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.

    14. Re:You mean... by jma05 · · Score: 5, Interesting

      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.

    15. Re:You mean... by quanticle · · Score: 1

      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.

      --
      We all know what to do, but we don't know how to get re-elected once we have done it
    16. Re:You mean... by Anonymous Coward · · Score: 0

      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.

    17. Re:You mean... by Anonymous Coward · · Score: 1, Interesting

      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.

    18. Re:You mean... by marcello_dl · · Score: 2, Informative

      >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.

      You may also want to check out lighttpd. It's smaller and faster than apache on static content (dynamic content depends on cgi speed, I guess ;) )

      --
      ---- MISSING MISCELLANEOUS DATA SEGMENT --- [sigdash] trolololol
    19. Re:You mean... by stuntpope · · Score: 1

      Plus, it's been around for quite some time, as have been many other Python web frameworks (look for the Python framework shoot-out if interested). I evaluated it more than a year ago but didn't go with it.

      Anyway, what's "hot" in Python for web currently is Django.

    20. Re:You mean... by Marc2k · · Score: 1

      Uh, whoa. Hold on there, chief. I didn't, shall we say, "read the article", per se, but I can tell you right off the bat that this "new technology" is not single-threaded, it's just carried on from one process. Maybe you'd like to call them "light-weight processes", but these days, one process can host a myriad of threads, each doing their own thing. What was that about being a senior programmer, now?

      --
      --- What
    21. Re:You mean... by AstroDrabb · · Score: 1
      Uh, whoa. Hold on chief. Did you even read my reply to someone else (poster nxtw)? It was a JOKE.
      What was that about being a senior programmer, now?
      What was that about having an IQ above 80 that would help you understand someone being facetious (I know, it is a big word for you) vs. being serious?

      Oh, and thank you "Captain Obvious" for telling us that:

      these days, one process can host a myriad of threads, each doing their own thing
      I really wish /. would require a simple IQ test before someone could get an account. It would really stop people like you from making incredibly stupid posts!
      --
      If Tyranny and Oppression come to this land,
      it will be in the guise of fighting a foreign enemy. -James Madison
    22. Re:You mean... by MikeFM · · Score: 1

      I like CherryPy because it is very lightweight and doesn't rely on an external webserver. It's especially well suited to tasks such as web-based system managers. Afterall, it really sucks to enter changes into your web-based web server configuration manager only to find out that your changes broke the web server so you can no longer configure said web server. I converted my existing mod_python scripts to CherryPy and have so far had very good luck with it.

      Python is a much better language for writing complex programs in than PHP, Perl, or things like ColdFusion and it's less resource intensive than Java which is good for the kinds of lightweight tasks web-based apps usually do. Very good reasons to give Python a try for your development.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
    23. Re:You mean... by Marc2k · · Score: 1

      Oh, and thank you "Captain Obvious" for telling us that:

              these days, one process can host a myriad of threads, each doing their own thing


      Guess what I was being? That's right, facetious ! Congratulations.

      I only replied because I didn't find your comment very funny, and I don't like people who put pretentious things like "Senior Programmer" in their signature, if I wanted to know what your title at work was, I would ask you; otherwise, I'll judge what I think of you by what you say (though this _is_ Slashdot, and I just don't really care). Also, this rule applies to your comment, haccording to the Purdue University writing lab, Do not use quotation marks for common nicknames, bits of humor, technical terms that readers are likely to know, and trite or well-known expressions. Obviously, you're not a Senior Grammatist.

      --
      --- What
    24. Re:You mean... by AstroDrabb · · Score: 1
      don't like people who put pretentious things like "Senior Programmer" in their signature
      Oh, you just like people who put "witty" sayings in their sig such as yours?
      /* Imma squeeze out some more karma by putting a C-style comment in my sig */
      Heh, heh, heh. That is just great. I bet your just "the" elite /. user aren't you? Boy, I wish I could have come up with a great sig like yours! I bet your some 133t hacker huh?
      Obviously, you're not a Senior Grammatist
      Ahh, yes, your sig is a well structured and grammatically correct sentence. Hmm, "Imma squeeze out", yup, that certainly passes the test!

      What is more pretentious than putting ones title in their sig, are idiots like you who complain about them. Wake up, I don't come to /. for you or your opinion, neither does the rest of /..

      --
      If Tyranny and Oppression come to this land,
      it will be in the guise of fighting a foreign enemy. -James Madison
  2. Obligatory by Limburgher · · Score: 4, Funny

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

    --

    You are not the customer.

    1. Re:Obligatory by Anonymous Coward · · Score: 2, Insightful

      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

    2. Re:Obligatory by Anonymous Coward · · Score: 0

      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.

    3. Re:Obligatory by strider44 · · Score: 1

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

    4. Re:Obligatory by SilicaiMan · · Score: 1
      You're missing a few leading spaces.

      /me ducks and runs for cover ...

    5. Re:Obligatory by strider44 · · Score: 1

      ... and python, which is what we're talking about here *hint hint*

    6. Re:Obligatory by jericho4.0 · · Score: 1

      Actually, the semicolon means the same thing to the python interpreter as to gcc, a end-of-statement toke. You just don't need it.

      --
      "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
    7. Re:Obligatory by Roberto · · Score: 3, Insightful

      How hard is it to try it? Not hard.

      [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> a=1;b=2
      >>> a
      1
      >>> b
      2
      >>>

    8. Re:Obligatory by strider44 · · Score: 1

      Perfectly right. It doesn't mean "jack shit". It means change units.smile.face.width to "Miles" AND change smile.face.width to "10". (You obviously don't have a *n*x box otherwise you could have better spent the time writing that post typing "python" into a command line and testing it)

    9. Re:Obligatory by masklinn · · Score: 1

      oh god...

      May i ask a mod passing by to mod all my previous posts of this thread "-1 fucktard"? thank you

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    10. Re:Obligatory by Anonymous Coward · · Score: 0

      The parent is not a troll, merely a dumbass who took Python's no-semicolon 'rule' way too seriously.

    11. Re:Obligatory by Anonymous Coward · · Score: 0

      I disagree, they're not equivalent at all.

      The original code changes a "width" value on two objects, one of which ultimately descends from a "units" object. That kind of structure makes no sense. I wasn't making a point about semicolons (though I didn't know you could use them in Python, so I've learned something as well).

  3. PyDie by Anonymous Coward · · Score: 2, Funny

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

    1. Re:PyDie by tepples · · Score: 1

      Speaking of pie, can anyone recommend some good recipes?

      Recipes for pi are from "Analysis" down to "Open questions" of this article.

      Wobbl and Bob are looking for some pi based action.

  4. So, we now have by TDScott · · Score: 3, Insightful

    Regular CGI, mod_perl, mod_python, the newcomer Ruby on Rails, and now CherryPy. Granted, some webhosts 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?

    1. Re:So, we now have by stuntpope · · Score: 1

      And now? CherryPy has been around for a couple of years at least. When I started my excursions outside of Zope back then, I had the option of using CherryPy, Albatross, SkunkWeb, Quixote, WebWare, and more I've forgotten. Apparently lot of people have that web framework itch.

    2. Re:So, we now have by Itchy+Rich · · Score: 1

      But at what point does it start to become a burden to keep up with all these...for hosts wanting to stay current?

      How long is a piece of string?

      Some hosts already don't keep up with security patches for the software they already run, but the ones that make this available are likely to be the ones with the resources to maintain it; the others wont bother.

      But at what point does it start to become a burden to keep up with all these.. for programmers looking to keep their CVs up to date?

      I'm not sure getting every latest tech fashion on your CV is as important as you might think. For each person trying to get CV-points there's someone else trying to look past all the buzzwords and bull and figure out whether you're diligent and resourceful.

  5. Umm.. by Anonymous Coward · · Score: 3, Informative

    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.

    1. Re:Umm.. by dotgain · · Score: 2, Interesting
      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 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.

    2. Re:Umm.. by afd8856 · · Score: 1

      See this, computer languages shoutout benchmark Bigger is better, python is at 17, a few places behind C, perl is at 10. You wouldn't disregard perl when it comes to web frameworks, right? I don't know about emerge, or for example, up2date from fedora, but python programs don't have to be slow. I'm using zope and plone, and, for their complexity, they're fast enough. Another example: the Battlefield game series use python as internal scripting language.

      --
      I'll do the stupid thing first and then you shy people follow...
    3. Re:Umm.. by Tony+Hoyle · · Score: 1

      Did you read the top of that page? It's supposed to be a joke...

      "What fun! April Fool's Day all year long! Can you manipulate the multipliers and weights to make your favourite language the fastest programming language in the Shootout?

      And remember, languages that implement more benchmarks will move to the top of the list, and those with many missing benchmarks will stay at the bottom!"

      That said, in the direct comparison there are no places where perl uses less memory or CPU than python, so you can't fudge there results enough to make perl faster (or at least I couldn't find a way in 5 minutes).

    4. Re:Umm.. by mixmasta · · Score: 1

      Ok, I'll reply.

      Python is fast enough for most applications, and it has improved significantly in the latest releases, 2.3 and 2.4. It's not much slower than perl and is a much nicer language, IMHO. I've used it on countless projects without problem or performance issues.

      If performance is your primary concern, you wouldn't be using python, and you wouldn't be using CGI obviously so the question is not so relevant, I think.

      As for emerge, it's slow response comes from the non optimized way it scans a database of many thousands of flat files of dependencies, etc. As far as I know it does it every time you run the command, there may be no caching or indexing at all.

      Obviously, a very slow but useable implementation of one program is not python's fault. The program and even the problem itself could be optimized in any number of ways, and there is talk in the gentoo dev camp on how to do that. Whether there is the will to do it is another question. They may have to redesign the complete packaging system and portage to do it.

      --
      #6495ED - cornflower blue
    5. Re:Umm.. by dotgain · · Score: 1
      Hi. "Not much slower than Perl" I can agree with. My friend further up the page, of course, insists that Python is fater than Perl. I think what we can learn from this is that he can't program in Perl, and can in Python, hence it being faster.

      Admittedly, I was picking on Gentoo Portage, not python in my last paragraph, and I probably shouldn't have. Yes, 'emerge' and portage are god-awful and the only reason I stopped using Gentoo. It's so slow that I had to put it down to much more than inefficient database usage, although upon studying it, it seems the gentoo devs really went out of their way to make the portage database slow, and emerge may be unusable simply because of this after all.

      Sincerely, thanks for your reply.

  6. Whoops - sorry, to head off any criticism: by TDScott · · Score: 4, Informative

    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.

    1. Re:Whoops - sorry, to head off any criticism: by baadger · · Score: 1

      Although it is a referral link it just redirects to "http://www.dreamhost.com/" for me without setting any cookies (I restrict my cookies) or introducing any ?r=username referralish bits into any other links.

      Their referral script is obviously either very dumb or very cunning.

    2. Re:Whoops - sorry, to head off any criticism: by Some+Random+Username · · Score: 1

      Sessions still need your browser to send the session id with every request, either in a cookie or with an ugly session_id=spdfiyasfduiahsdfp97safaishfpa8fadf89a7 d9f8sdyuf8usdf8 in the url.

    3. Re:Whoops - sorry, to head off any criticism: by elemental23 · · Score: 1

      Their referral script will normally redirect you to the site root after setting a cookie with the referral ID. Denying cookies will obviously foil this.

      --
      I like my women like my coffee... pale and bitter.
  7. Give me a reason to use this by wilsoniya · · Score: 2, Interesting

    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

    --
    I can't remember the last time I forgot anything.
    1. Re:Give me a reason to use this by Poromenos1 · · Score: 3, Interesting

      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.

      --
      Send email from the afterlife! Write your e-will at Dead Man's Switch.
    2. Re:Give me a reason to use this by Nasarius · · Score: 4, Interesting

      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.

      --
      LOAD "SIG",8,1
    3. Re:Give me a reason to use this by utnow · · Score: 0

      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.

    4. Re:Give me a reason to use this by Anonymous Coward · · Score: 0

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

    5. Re:Give me a reason to use this by foote · · Score: 1

      I'd be interested in benchmarks as well. But note that CherryPy is not new; it's been in development since at least 2001.

  8. CGI's my cherry pie by computerjunkie · · Score: 3, Funny

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

    1. Re:CGI's my cherry pie by Conspiracy_Of_Doves · · Score: 1

      Ok kids, who saw that one coming?

  9. What being in a single process really means by MostlyHarmless · · Score: 5, Informative

    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.)

    --
    Friends don't let friends misuse the subjunctive.
    1. Re:What being in a single process really means by nxtw · · Score: 2, Informative
      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.

    2. Re:What being in a single process really means by turnerjh · · Score: 1

      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.

    3. Re:What being in a single process really means by joib · · Score: 1

      I'd say the counterargument to this is that:

      1) python multithreaded scalability is limited by the global interpreter lock.

      2) With a multi-process model you can use memcached to cache stuff in memory without going via the DB. Additionally, with this architecture horizontal scaling is also possible.

      3) A multi-process model is pretty robust. If one process dies, apache restarts it. If your application, or the app framework etc. suffers from a memory leak, you can configure apache to let each process handle only a limited number of requests until it is killed and restarted.

    4. Re:What being in a single process really means by 1110110001 · · Score: 1

      ... , you can share items in memory that would otherwise have to go through the database, ...

      Like with shared memory? But shared memory also works with multiple processes. And if you've more than one webserver (scaling and stuff) you still need a central data storage, like a database or a simpler session storage (i.e. msession).

      b4n

  10. People are looking at this the wrong way by sean23007 · · Score: 5, Interesting

    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

    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.

    --

    Lack of eloquence does not denote lack of intelligence, though they often coincide.
    1. Re:People are looking at this the wrong way by melted · · Score: 1, Insightful

      >> 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.

    2. Re:People are looking at this the wrong way by Anonymous Coward · · Score: 0

      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!

    3. Re:People are looking at this the wrong way by Anonymous Coward · · Score: 0
      >> 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"...

    4. Re:People are looking at this the wrong way by civilizedINTENSITY · · Score: 2, Informative
      "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 for the latter, or The Tcl/Java Project, or The scheme package for Java based scheme. lists some 200 languages that have been ported to the JVM.)
    5. Re:People are looking at this the wrong way by Beek · · Score: 3, Informative

      > 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

      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.)

    6. Re:People are looking at this the wrong way by jarich · · Score: 1
      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! :)

    7. Re:People are looking at this the wrong way by Anonymous Coward · · Score: 0

      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.

    8. Re:People are looking at this the wrong way by chez69 · · Score: 1

      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.

      --
      PHP is the solution of choice for relaying mysql errors to web users.
    9. Re:People are looking at this the wrong way by ziplux · · Score: 2, Informative

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

    10. Re:People are looking at this the wrong way by Anonymous Coward · · Score: 1, Informative

      as does perl's catalyst.

    11. Re:People are looking at this the wrong way by jarich · · Score: 1
      Thanks! http://www.jaredrichardson.net/blog/2005/08/21/

      btw, your home page link (http://www.jaredcam.net/ goes to the default Apache greeting instead of a real page. FYI...

    12. Re:People are looking at this the wrong way by jma05 · · Score: 4, Insightful

      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.

    13. Re:People are looking at this the wrong way by jma05 · · Score: 1

      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.

    14. Re:People are looking at this the wrong way by masklinn · · Score: 1

      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...

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    15. Re:People are looking at this the wrong way by Ian+Bicking · · Score: 2, Insightful
      Python frameworks are now catching up to things like ASP and PHP
      While Python web programming has some issues, "catching up" isn't really how I'd describe it. Even in the most basic of Python frameworks you get more expressive power than in ASP and PHP. You also get equivalent performance to PHP (I can't say much about ASP -- but Python is fast enough which is all that matters). In terms of expressiveness Python beats the pants off PHP, Visual Basic, C#, and Java. There's no "catching up" there at all, they were long since passed.

      But I'd certainly agree the single process thing is a red herring; it's not what makes CherryPy interesting.

    16. Re:People are looking at this the wrong way by 1110110001 · · Score: 1

      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).

      Ok so you're code is running faster. And that brings you? Nothing. You're code is just waiting faster for data from the network or the database or the filesystem. If your code is good it doesn't matter if it's written in PHP, ASP, Python, Perl, Ruby, ... because it's always fast enough for the web.

      b4n

    17. Re:People are looking at this the wrong way by Anonymous Coward · · Score: 0

      Try saying that again after you have a few hundred people hitting your site every minute.

    18. Re:People are looking at this the wrong way by freeplatypus · · Score: 1

      You were trying to get modded 'Flamebait' or do You have something to support Your statement? I am asking from curiosity because I was once thinking about trying Struts but I never made it.

    19. Re:People are looking at this the wrong way by stuntpope · · Score: 2, Interesting

      I love all this "x has that already" talk when CherryPy has been around for years before some of the x's.

    20. Re:People are looking at this the wrong way by masklinn · · Score: 1

      Matt Raible's Comparison of Web Frameworks would be a good start for you, along with the Equinox demo

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    21. Re:People are looking at this the wrong way by freeplatypus · · Score: 1

      Ok, the source You gave is nice and I already noticed that ActionForms are considered painful as I suspected. But I am curious what was meant in GP post, that Struts (especially with Tomcat) is the worst piece of crap?

    22. Re:People are looking at this the wrong way by 1110110001 · · Score: 1

      1600 req/min is what you're talking about? And the servers are still bored. At least mine. And that with PHP 4.3 - 5.1 is much faster. And if the machines are no longer bored we'd just a server - PHP is very good at scaling.

      As I said - clean code - no problem.

      b4n

    23. Re:People are looking at this the wrong way by CableModemSniper · · Score: 1

      And speed wise Python kicks Ruby's ass [debian.org] for now.

      Probably true statement, poor choice of reference material.

      --
      Why not fork?
  11. Cool! by smoondog · · Score: 4, Interesting

    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.

    1. Re:Cool! by hoka · · Score: 3, Interesting

      What I've encounted with Python is the overwhelming lack of crypto, not necessarily a lack of "security" (I use that term loosely here). What stems from the lack of good default crypto is a sense of a lack of security. For example, the Python SSL implementation has no certificate verification, which is a huge problem for anybody who wants to do any client work. There is also a complete lack of support in most libs for servers (https server? secure xmlrpc server?). This means that you can only half-ass the client side, and the server side is non-existant. While I havn't looked at the framework, I'm hoping that they implemented extra features into the system that makes it a bit better of a choice for security reasons. Right now I'm having a hell of a time trying to get some basic solid crypto security going over xmlrpc.

    2. Re:Cool! by Anonymous Coward · · Score: 0

      Python is just a programming language. The fact that it has an HTTP server in the basic library is pretty cool, but I guess no-one expected you to want to do HTTPS in an interpreted language. Apache does HTTPS pretty well, and CherryPy will hook into Apache for that more heavyweight work.

    3. Re:Cool! by stuntpope · · Score: 1

      I've just run into the same issue with needing authenticated and encrypted XML-RPC between servers, using Python. First was the issue of non-authenticating xmlrpclib, then discovering the lack of built-in SSL support. What have you come up with? (and not M2Crypto).

    4. Re:Cool! by Anonymous Coward · · Score: 1, Interesting

      My solution currently is server-side only (SecureXMLRPCServer) which comes as an example with PyOpenSSL, I hacked on it a bunch so that it supports things a bit better, but its a nice base to get a secure server going. Right now I'm trying to rewrite a SecureTransport that is better than the SafeTransport included in the base xmlrpclib. If you need something quick, Twisted has a out-of-the-box ready Transport that uses their library, and hook that up with the pyopenssl (or just write one of your own) server and you can just dial in verification callbacks as you see fit.

    5. Re:Cool! by schon · · Score: 1

      I guess no-one expected you to want to do HTTPS in an interpreted language.

      Why not? Roxen and Caudium both do it (Pike is interpreted), and (at last check) do it faster than Apache.

  12. People are looking at security the wrong way by Anonymous Coward · · Score: 1, Insightful

    "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] "

    And the security issue?

    1. Re:People are looking at security the wrong way by jma05 · · Score: 1

      "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.

  13. Its all in the marketing .... by Anonymous Coward · · Score: 1, Interesting

    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. :-) :-) :-)

  14. Nevow by kevin_conaway · · Score: 4, Informative

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

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

  15. Uhh.... Single-process? by Anonymous Coward · · Score: 0

    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.

  16. " All it does is..." by LionKimbro · · Score: 5, Interesting

    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 and 5 custom web apps and a few WordPress installations on my server.

    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 or AutoXmlRpcCgi 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.

    1. Re:" All it does is..." by Anonymous Coward · · Score: 2, Funny

      Perhaps.

      You could put more than one thought.

      On each line.

    2. Re:" All it does is..." by Ian+Bicking · · Score: 2, Informative
      The Python WSGI spec (PEP 333) is trying to address exactly this issue. And I agree it's an issue -- I maintain quite a lot of Python applications (not in CherryPy, but same basic setup) and it can be really annoying. CherryPy supports WSGI, though its WSGI support isn't perfect (but they're aware and working on it).

      Relatedly I just released Paste Deploy, which is also intended to address these issues. It's just a small piece that will only be useful given more infrastructure support, but I'm optimistic. In the end I think it will mean some specific setup to support Python applications on a server, but once the basic support is configured adding an application should be a one-line affair.

    3. Re:" All it does is..." by Floody · · Score: 1

      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 and 5 custom web apps and a few WordPress installations on my server.

      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.


      After a quick glance (although I haven't looked deeply into it, so I could be talking straight out of my ass here), seems like it should be a snap to wrap/inherit CherryHTTPRequestHandler and plug cherry right into mod_python. Like all things python, it's pretty much just your basics from httplib. What, maybe 50-70 lines of code?

      Similarly, you can plug such a wrapper into the fcgi module and get fastcgi running, if that's your thing. Even single process fastcgi w/ multithreading on the back-end.

  17. Seems only useful if you already do Python CGI. by mcc · · Score: 2, Insightful

    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?

    1. Re:Seems only useful if you already do Python CGI. by justrob · · Score: 5, Informative

      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 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".

    2. Re:Seems only useful if you already do Python CGI. by Ian+Bicking · · Score: 2, Informative

      Leonard Richardson, who wrote the article in question, also recently wrote articles on SQLObject and Cheetah.

  18. Other python based web interfaces ? BEST ? by vortek · · Score: 1

    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.

  19. People are looking at this the wrong way by darekana · · Score: 3, Interesting

    Actually I think CherryPy and Zope have been around a while before Ruby on Rails. And speed wise Python kicks Ruby's ass 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.

  20. Gee, it sounds just like... by mengel · · Score: 3, Informative
    ... FastCGI which has had a several python modules 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
    --
    - "History shows again and again how nature points out the folly of men" -- Blue Oyster Cult, 'Godzilla'
    1. Re:Gee, it sounds just like... by Anonymous Coward · · Score: 1, Informative

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

  21. Obligatory Quip by Dark+Coder · · Score: 1

    Easy as pie?

  22. django! (/. missed the hype train) by brendano · · Score: 5, Interesting
    The big thing in python web programming right now is the introduction of Django, 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...

    --
    -Brendan
  23. Wow, dude. Chill. by jbellis · · Score: 3, Insightful

    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.

  24. hmm, maybe .. by josepha48 · · Score: 1
    .. 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 ....

    --

    Only 'flamers' flame!
    Does slashdot hate my posts?

    1. Re:hmm, maybe .. by jma05 · · Score: 1

      Already been done. It's called mod_python.

    2. Re:hmm, maybe .. by josepha48 · · Score: 1

      so why do we need this then?

      --

      Only 'flamers' flame!
      Does slashdot hate my posts?

    3. Re:hmm, maybe .. by jma05 · · Score: 1

      mod_python is for apache only. This one is self contained. Your script itself becomes the web server. That presents a different picture. For example, it runs with your own permissions rather than Apache's (mod_python servlets are apache owned, not user owned since Python VM is now a part of Apache).

      Very often for small web apps, all the code is in just one file - no seperate server, no server configuration. For me, CherryPy is simplicity. I use mod_python too, but for a different kind of apps.

  25. rm -Rf by PhYrE2k2 · · Score: 1
    --

    when you see the word 'Linux', drink!
    1. Re:rm -Rf by sean23007 · · Score: 2, Informative

      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.

      --

      Lack of eloquence does not denote lack of intelligence, though they often coincide.
  26. Bah, Scripting languages by Jessta · · Score: 1, Troll

    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

    --
    ...and that is all I have to say about that.
    http://jessta.id.au
    1. Re:Bah, Scripting languages by Hoxworth · · Score: 1

      "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)?

    2. Re:Bah, Scripting languages by Jack9 · · Score: 1

      >>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.

      --

      Often wrong but never in doubt.
      I am Jack9.
      Everyone knows me.
    3. Re:Bah, Scripting languages by Jessta · · Score: 1

      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.

      --
      ...and that is all I have to say about that.
      http://jessta.id.au
    4. Re:Bah, Scripting languages by masklinn · · Score: 1
      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)

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    5. Re:Bah, Scripting languages by masklinn · · Score: 3, Informative
      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).

      Beeep, wrong

      Python is not based on any "java ideal", and everything in python is indeed an object, a module is an object, a function is an object, and "1" is an object by itself.

      And it can't be compiled, it's a purely interpreted language, it's merely loosely syntax-checked and translated to bytecode (not compiled mind you, that's several steps under java). Some utils write machine code at "compile time" (Psycho), but it's not built in the base language in any way.

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    6. Re:Bah, Scripting languages by Anonymous Coward · · Score: 0

      I suspect that you intended your question (what is the difference between... etc) to be rhetorical, however it really isn't; rather, it just suggests a lack of knowledge of the subject matter. Can't speak much about Ruby, but similarities amongst the other three are few and far between.

      Anyway, others have answered your questions, however it may be worth pointing out that Parrot http://www.parrotcode.org/ is designed to be just that; a VM for execution of interpreted bytecode, with Perl6 (such as it is) already on board and Python, Scheme, TCL, Ruby and others in mind for the future.

    7. Re:Bah, Scripting languages by Anonymous Coward · · Score: 1, Informative

      "original features like being able to pass closures"

      Lisp, anyone?

    8. Re:Bah, Scripting languages by Jack9 · · Score: 1
      Python is not based on any "java ideal", and everything in python is indeed an object, a module is an object, a function is an object, and "1" is an object by itself.

      I didn't imply it was based on Java or a Java idea. The idea that "everything is an object", is the Java ideal that I spoke of. Python is now specifically based on the Java ideal when it initially was simply extensible. Does that sound about right?
      --

      Often wrong but never in doubt.
      I am Jack9.
      Everyone knows me.
    9. Re:Bah, Scripting languages by Anonymous Coward · · Score: 0

      How is Python based on something that came out after it did?

      "Java was developed in 1991 by James Gosling and other Sun engineers, as part of the Green Project. After first being made public in 1994, it achieved prominence following the announcement at 1995's SunWorld that Netscape would be including support for it in their Navigator browser."

      "In the late 1980s, Van Rossum began work on Python at the National Research Institute for Mathematics and Computer Science in the Netherlands, or Centrum voor Wiskunde en Informatica (CWI) as it is known in Dutch."

      If you wish to become enlightened:

      http://www.artima.com/intv/python.html

    10. Re:Bah, Scripting languages by Jessta · · Score: 1

      Wonderful,
      Parrot looks quite interesting.
      Thank for the tip.

      - Jessta

      --
      ...and that is all I have to say about that.
      http://jessta.id.au
    11. Re:Bah, Scripting languages by Anonymous Coward · · Score: 1, Informative

      Not particularly, no, OO predates Java by far and considering in Java everything is NOT an object, their claim to that phrase is ridiculous at best. If "everything is an object" ideal comes from somewhere, it's Smalltalk.

      Nor would I be particularly surprised if Python were quite object oriented from the beginning,

    12. Re:Bah, Scripting languages by Jack9 · · Score: 1

      >> How is Python based on something that came out after it did?

      It's called having direction. If the language implements features of other languages, I find it fair to say it's based on a common denominator. I read the history of Python (from the python.org faq) before posting. My viewpoint hasnt changed.

      As an aside, nothing I've heard about Python in this discussion has increased my respect for Python as a language. What is the strength of Python? The Python FAQ topic 1.1.3 What is Python good for? avoids the question that it's supposed to answer!

      --

      Often wrong but never in doubt.
      I am Jack9.
      Everyone knows me.
  27. For windows users... by Jeffus · · Score: 2, Funny

    ...how about a piece of ApplePy?

    1. Re:For windows users... by lukelele · · Score: 1

      That would involve eating some HumblePy first. Too filling ;)

  28. Quixote does XMLRPC easier... by Anonymous Coward · · Score: 1, Informative

    As an alternative, Quixote http://www.mems-exchange.org/software/ 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.

  29. Re:Python GUI kit by Anonymous Coward · · Score: 1, Funny
    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!

  30. Re:django! (/. missed the hype train) by lukelele · · Score: 1

    heh. no, i think you missed the /. hype train. Posted Aug 02

  31. Re:One... by larry+bagina · · Score: 1

    sounds familiar...

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  32. That's the same thing as a servlet by irritating+environme · · Score: 1, Redundant

    Welcome to 1998.

    --


    Hey, I'm just your average shit and piss factory.
    1. Re:That's the same thing as a servlet by Anonymous Coward · · Score: 0

      Yep, that was my first thought. Not even mentioning that an application server probably exposes a lot more functionality (like persistent session data storage), scalability, and performance than this CheryPy thing.

    2. Re:That's the same thing as a servlet by irritating+environme · · Score: 1

      Seriously, if they want scripting and web, do Groovy. Python already leeches off of the Java API with Jython, why not just do the full switch.

      --


      Hey, I'm just your average shit and piss factory.
  33. Ahhh, injection attacks by irritating+environme · · Score: 1

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

    --


    Hey, I'm just your average shit and piss factory.
  34. not so easy by subtropolis · · Score: 1

    it's barely still virgin

    --
    "Our interests are to see if we can't scale it up to something more exciting," he said.
  35. Careful now. by Whizzmo2 · · Score: 1

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

  36. Re:Wow, dude. Chill. by LionKimbro · · Score: 2, Interesting
    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!
  37. 80's flashback by QuantumMajo · · Score: 2, Funny

    Man this is bad but when I read the header to this article, the first thing that came to mind was Warrant ...

  38. Shameless Plug by bobintetley · · Score: 1

    I run a project that aims to be a java port of CherryPy. Supports all free vms and is very lightweight.

    OOWeb

    /plug
    1. Re:Shameless Plug by Anonymous Coward · · Score: 0

      Jetty anyone?

  39. Re:So its a Servlet then? by Anonymous Coward · · Score: 0

    You realise this is hardly anything new as well, right?

  40. Re:So its a Servlet then? by jma05 · · Score: 1

    Of course. I never said it was new idea :-). CherryPy itself is not a very new framework either. It's been around for a while. It's just one of the clean frameworks out there in an over engineering world.

  41. Clue-stick by Anonymous Coward · · Score: 1, Informative
    Why is CherryPy good? It makes the simple cases REALLY simple, and it can get out of your way if you have more complex cases.
    def index():
        return 'Some text'
    index.exposed=1
    How simple? Your form submissions get turned into variables passed to the action page, which is a normal function.

    For instance, if your form has fields Name and Password with action="loginUser", you write this:
    def loginUser(Name, Password):
        #... stuff goes here
     
    loginUser.exposed=1
    And the arguments will be automatically passed. With CherryPy, your web app embeds its own multi-threaded web server; one practice is to put it behind Apache, so you can integrate it with already existing setups. It supports the Python Web Server Gateway Interface (WSGI) so you can use mod_python, IIS/ASP, FastCGI, SCGI , etc.

    The ability to use Python makes web programming bearable again. Want something cool? SQLObject turns your SQL (MySQL, PostGres, others) into Python objects.
    dude=Person.get(1) # SELECT * from TABLE where ID=1
     
    dude.name='Fred' # UPDATE TABLE SET name='Fred' WHERE ID=1
    What's more, you don't have to define your class in code. You can read it straight from the DB schema:
    class Person(SQLObject):
        _fromDatabase=True
    You can also combine CherryPy with your choice of templating system. And for version control, check out how Trac works with SVN at the CherryPy site.

    If you're sick of PHP, learn Python and enjoy programming again.
  42. Plodding Python? by crucini · · Score: 2, Interesting

    I don't know much about Python, but I doubt that emerge's slowness comes from Python. It's probably doing a linear scan of something that should be indexed more intelligently. Or maybe it's opening a huge number of files.

    A similar thing applies to web apps - a slow web app is usually due to high-level design errors, not a slow scripting language. A lot of web apps spend most of their time in database calls. When an app is blocked on I/O, it's just as fast in Python as in C, much like a Porsche stuck next to a Yugo in traffic.

    Perl is not exactly a speed champ compared to C, but many snappy web pages run on Perl because the amount of computation involved in sending the web page is relatively small. Is Python substantially slower than other scripting languages?

  43. Re:Wow, dude. Chill. by Anonymous Coward · · Score: 2, Insightful

    What your post boils down to is you complaining that in order to use something new, you have to learn something new.

    Well, duh.

    Anyway it's all here: CherryPy behind Apache

  44. Food File Online by willm5 · · Score: 1
    CherryPy does make web applications a breeze.

    I used CherryPy to turn the public domain US Department of Agriculture's nutrient database in to a profitable website, Food File Online. The single script used to power it represents just under one weeks work!

    1. Re:Food File Online by asdcore · · Score: 0
  45. Python is some good stuff... by Anonymous Coward · · Score: 0


    One of the major things that makes Python acceptable is that it's ability to use C or C++ code as modules.

    This is basicly how it goes..

    You write the program to be 'correct' in python. Since python is very quick programming language to program with this initial stage can be done much quicker then with traditional languages such as C++ or Java. Generally python programmer's generate programs faster and with less bugs then other programmers.

    Then when you get the program finished and it's tested it may be to slow for the workload. Python is a fast language to program, but it produces slower programs sometimes. (although memory use is much much less then thru normal vitual machine languages like Java)

    There are some simple 'magic' you can sprinkle around like Psyco to generate faster code, but often that's not quite enough.

    What you do then is you do profiling on the actual program. That way you find out what _actual_ parts of the program take up the most resources.

    Often on programming your forced to guess what parts of the code will be slow and spend more time on those portions. With python and the ability for rapid profiling you can find out on a living breathing program what parts are slow.

    Then you take those parts and optimize them by cleaner/better code or thru rewriting those portions in a C or C++ and incorporating that functionality back into the program as modules.

    That way you end up with a Python program that is just as fast as anything else because you've been able to more accurately determine what parts of the program needs the most work and time spent on it.

    The drawback is that there is a significant amount of "glue" that is needed to build python modules so it's not as straightforward as it sounds at first... but there are some very nice tools to help with that.

    For instance you have Boost.Python, and of course SWIG.

    Then there is more cool stuff, like Psyco, which can increase math operations substantially... But one interesting one is Pyrex...

    Pyrex allows you to write 'C' modules by using a special language that is a combination of most legal python with most legal C. Work is ongoing for C++-like support. It takes what you program, turns it to C then it is compiled using the normal GCC compiler. Very interesting for quickly getting solid modules built.

    That's the advantage of Python. It allows you to use those CPU cycles to your advantage, but doesn't abuse them. If your a experianced C programmer then python is a complete breeze and you don't have to abandon your skills to learn the 'corporate'-hyped languages.

    It's very cool language for newbies and gurus alike and not only ties very well into the Unix enviroment, but is very Windows-freindly too.

    For isntance you can take Python code with numerious third-party add-ons and dependancies and such and turn it all into a single *.exe standalone executable for windows enviroment.

  46. Link to CherryPy website by Anonymous Coward · · Score: 0

    The link to the CherryPy website is http://www.cherrypy.org/
    Maybe the post should be updated to include this.

  47. This is equivalent to Zope, circa 1999 by Anonymous Coward · · Score: 0

    This is what the Zope server, at its very guts in the ZPublisher module, does.

    Of course, CherryPy is a more recent construction, but the basic concept isn't all that surprising.

  48. Very nice framework... by Anonymous Coward · · Score: 0

    Lacks threading though. Try this:

    from cherrypy import cpg

    class App:
            @cpg.expose
            def index( self ):
                    from time import sleep
                    sleep( 15 )
                    yield "done"
            @cpg.expose
            def test( self ):
                    yield "test"

    cpg.root = App()
    cpg.server.start()

    Point your browser at http://localhost:8080/
    and while index() is sleep()'ing, try to open
    http://localhost:8080/test/ in another window.
    It won't respond until previous request answers.

    1. Re:Very nice framework... by Roberto · · Score: 1

      Urgh. No, it's not that, it's that you have not read the docs.

      Put this as x.conf:

      [server]
      socketPort = 8080
      socketHost = 127.0.0.1
      threadPool = 10

      Then do a cpg.server.start('x.conf')

      and see what happens.

      I mean, really, did you think someone would publish a web framework that could only handle 1 concurrent request? Are you stupid?

  49. Don't forget Catalyst! by Black+Perl · · Score: 1

    Rails and Struts already have this feature.

    Don't forget Catalyst!

    Of course, being later to the game allowed Catalyst to one-up the competition with the utmost in flexibility: full regex-based URL handlers!

    --
    bp
    1. Re:Don't forget Catalyst! by Beek · · Score: 1

      You can this with Rails too. There's a lot you can do with routes.rb since really, it's just code, not a configuration file.

    2. Re:Don't forget Catalyst! by CableModemSniper · · Score: 1

      With mod_rewrite you can do that with any CGI in any language.

      --
      Why not fork?
    3. Re:Don't forget Catalyst! by Black+Perl · · Score: 1

      With mod_rewrite you can do that with any CGI in any language.

      Not quite. You'd still have to have a canonical URL handler with a different format. Then you have two things to maintain.

      --
      bp
  50. Re:django! (/. missed the hype train) by ddilling · · Score: 1

    If I had moderator points right now, I would mod you funny, because you can't seriously be saying that you dislike having a hard time seeing your url space with CherryPy, and in the same breath recommend that mangled vomit of regex instead. :)

    --
    Mahnamahna!
  51. Quick fix for 2.1 by mav[LAG] · · Score: 2, Informative

    If you're like me and downloaded the latest cherrypy to follow along with the article, there's a quick fix that will make version 2.1 work with it. Just change any lines that say:

    from cherrypy import cpg

    to:

    import cherrypy as cpg

    More info here.

    --
    --- Hot Shot City is particularly good.
    1. Re:Quick fix for 2.1 by mav[LAG] · · Score: 1

      Hmmmm. Obviously not content with duping stories, the editors are now duping posts as well! No idea why this got submitted twice...

      --
      --- Hot Shot City is particularly good.
  52. Quick fix for 2.1 by mav[LAG] · · Score: 0, Redundant

    If you're like me and downloaded the latest cherrypy to follow along with the article, there's a quick fix that will make version 2.1 work with it. Just change any lines that say:

    from cherrypy import cpg

    to:

    import cherrypy as cpg

    More info here.

    --
    --- Hot Shot City is particularly good.
  53. Re:django! (/. missed the hype train) by Ian+Bicking · · Score: 2, Interesting
    If we're talking about URL management, an interesting Python project is a port of Rails' Routes. This is notable in particular because it is reversable -- you can both unpack a URL to a controller and set of arguments, and pack a controller and set of arguments back into a URL.

    It's a very new project, so I don't think it's been used in any Python framework yet. But it would probably be applicable to quite a few of them (perhaps including CherryPy).

  54. No, the answer is more than it takes. by Some+Random+Username · · Score: 1

    You don't have to learn every framework to keep your resume up to date. If you are a competant programmer, you can pick up a new framework in a few days. If you know python already, learning cherrypy is trivial, and cherrypy isn't resume worthy anyways. That's like those idiots who put "word" as a skill on their resume. If you can't figure out how to work a different word processor then you shouldn't be looking for a job in IT.

    And if a webhost is any good, they don't have to keep everything up to date for you, you can install stuff in your home dir and use it there. That's what you have to do when you want to use a beta version of something anyhow.

  55. WTF are you talking about? by Some+Random+Username · · Score: 1

    Python is faster than perl. And its an order of magnitude faster than ruby, and rails seems to be giving everyone a permament boner lately.

    Frankly I don't think python is a contender for CGI programming. Nor do I think perl or any other interpreted language is. Stop using CGI, its 2005 for fuck's sake.

    1. Re:WTF are you talking about? by dotgain · · Score: 1

      I asked if anyone could "show me", not how anybody feels. And you say it's an "order of magnitude" faster than Ruby. While I can't be bothered verifying it, I can be certain that you don't know what you're talking about, and that you're a python programmer who only replied to me because you didn't have mod points.

    2. Re:WTF are you talking about? by Some+Random+Username · · Score: 1

      Nice try, but no. I don't like python. But just because I don't like it, doesn't change the fact that its faster. Nice that you can't be bothered to verify anything, but you expect us to do it for you?

      I say its an order of magnitude faster than ruby because it is. Try them, ruby isn't bytecode compiled like python and perl, its interpreted. Its brutally slow. Matz, the guy who created ruby and is still its primary developer says "ruby is slow". Its one of the big issues he is hoping to address in ruby 2.

      If you want to believe python is slow go right ahead, I don't really care. But if you want proof that it isn't, go ahread and benchmark it yourself. Any comparisons I or anyone else shows you will be shot down with complaints about it being biased or inaccurate.

    3. Re:WTF are you talking about? by joecode · · Score: 1
      Over and over again I kept hearing that mantra... "its 2005... now we have all these wonderful incredible technologies... ASP, Java Servlets/JSP, PHP, Ruby on Rails..."

      Well, I did a lot of research into this world of wonder before programming my site and that made the matter clear: we haven't advanced a damn bit. 2005 is hardly better than 1995, and arguably worse than 1985. Use fastcgi, use mod_perl, use C for goodness sake. Look for persistence, look for agility, look for speed ( gauge that according to the task!), and look for great libraries. But beyond that, it's a fools game.

      I'm not saying all the new frameworks and technologies have no place, but they have been grossly over-rated. I believe this modern refrain ("It's 2005") is reflective of a pi in the ski delusion of post-millenial programmers unwilling to come to terms with the unfortunate fact that it is 2005 and yet we are *still* programming, ultimately, nothing more than pages of Hypertext Markup Language. And I believe this because I recently shared, and subsequently got over, the same delusion. But how good it is to simply accept it!

  56. so wrong by namekuseijin · · Score: 1

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

    Machine code, yes. Only it is machine code ( bytecode ) for the CLR ( .NET's VM runtime ). Am i wrong or isn't it just when that bytecode gets loaded and handled to a JIT ( just-in-time ) compiler that it gets actually compiled to native machine code?

    BTW, i worked about a year on a system upgraded from ASP ( interpreted VBScript ) to ASP.NET ( bytecode compiled C# ). We wrote it from scratch, and only used the same DB stored procedures the original system also used. Well, guess what, smarty?! Performance sucked big time! The simple, interpreted ASP application was faster and less bloated.

    BTW, you know such a high-traffic as /. runs Perl, don't you?

    "before it's executed and runs "closer to the iron" (and therefore blows the doors off anything interpreted)"

    yea, my ass it is.

    --
    I don't feel like it...
  57. she's my..... by tq_at_sju · · Score: 2, Funny

    she's my cherryPy looks just like a stand alone app but its a cccccccggggggiiiiiii...sweet cherryPy

    --
    http://www.vanillaafro.com - take me seriously and I will shoot you
  58. persistance by Camel+Pilot · · Score: 1

    but it improves performance and gains persistence across requests by handling all its requests within a single process

    Persistance between browswer invocations can only be done via a cookie, hidden form variable or ip (which is not reliable). So saying that the single process gives you magical persistance is misleading - no? This same can be done with cgi simple and via apache modules.

    On thing a persistent single process can do for you is bring down the house with a memory leak.



    Mozilla users get Hot Sauce at a discount.

    ---------------

  59. Dude, you're clueless by melted · · Score: 1

    The difference between MSIL and Java bytecode is that MSIL was created to be quickly JITted before execution. Read up on this technology it's quite fascinating. Methods get compiled as son as they're called, on the fly and remain compiled into machine code for the life of the process. So you're running ONLY machine code when executing a page within ASP.NET. Heck, you can even pre-JIT your DLLs if you feel adventurous.

    Java bytecode, on the other hand was created to be run inside a VM, which means interpreted. Compiling Java into machine code is a lot more difficult and processor intensive a process as compiling MSIL. This is why only parts of Java bytecode get JITted by even the most recent VMs.

    1. Re:Dude, you're clueless by civilizedINTENSITY · · Score: 1

      My suggestion that the .NET CLR functions as a virtual CPU for a .NET program executing MSIL code was simplistic. MSIL is "compiled" into Portable Executable (PE) which is a collection of (MSIL) and Metadata. This is what I thought you were refering to. The CLR is designed to only produce machine code for what is actually going to run, for efficency. It is indeed possible to "bypass" the .NET framework by compiling everything to machine code (install-time code generation.)

      Code that targets the runtime is known as managed code. Apparently a single bit is set in machine code to indicate it once originated as managed code. Doesn't all verification occur prior to generating said machine code? If you generate machine code, then tweak it by hand, wouldn't you have (effectively)unmanaged code that would run as managed code? Seems like allowing "pre-verification" could be worrisome unless you could confirm that it hasn't changed since it was verified. Is it possible to set the enviornment so that precompiled executables would be trapped, and prevented from running?

  60. Did you reply to the wrong post by accident or something? What does anything you are saying have to do with my post?

    1. Re:huh? by joecode · · Score: 1

      Umm... in retrospect, yeah, replied to the wrong post. Or your post didn't say what I meant it to... Got avoid doing things like this late at night. Been working too hard, I guess.