As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
CherryPy vs Django, which would you use and why?
They're not exactly comparable. CherryPy provides url routing and a request/response abstraction, which makes prototyping very easy (although I find vanilla mod_python just as convenient). Django is a complete web application "stack", including a templating system and an object-relational mapper.
Django is vast, and difficult to learn, functions, tags and what not, you will absolutely are a computational genius if you have figured Django out completely. "full-stack" means every thing is available, you just have to spend the time looking for it :(
CherryPy is light and clean and far less complex. Compare the starter tutorials 1pg vs 4pgs you know what I mean. Its the difference between the "full-stack" java and the light and easy perl.
PS: the Django admin interface ROCKS!!
Though e.e. coli has already provided the accepted answer (and a good one at that), one thing I'll say in favor of CherryPy is that it is also implements WSGI out of the box. What this means is that, unlike the mod_python approach mentioned (which I believe is still an Apache-only solution)*, it provides abstraction from your web server. If you are all Apache all the time, this isn't so much a win, but if you ever think you may want to try alternate web servers, such as Lighttpd, then you can swap your web server w/o also having to make adjustments in your Python app. This was a big win for me personally.
*I don't mention Django here because I'm not a Django user (I don't like "full stack" frameworks) and so will leave any comments regarding it to it's many fans - all of whom are more qualified than I to answer questions about it.
Django, because the community is so much larger. You'll find more 3rd-party modules you can use and you'll find much more support.
I would use Django because of its large user base and existing modules (including the built-in admin interface) but I would imaging that CherryPy is more flexible than Django. You just have to look at the available options, figure out what you want to do and choose the platform that supports that the best.
CherryPy is web server "http framework", while Django supports web application front-to-end: it provides object-relational mapper, template, session management, automagically generates DB schema and all CRUD screens, and more.
I think they're both great, but I'm not a fan of full stack frameworks. CherryPy is a lot easier to use and much more flexible.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I've been developing a web server application with Django for the last year. The stack is Django + Apache + MySql. This stack was perfectly suited to our needs. Recently came the need of some real-time capabilities and the opportunity to change/rewrite a lot of stuff in the server application. To my surprise, Django is not the best option here.
I've been reading a lot (push, WebSockets, gunicorn... lots of stuff.. http://curella.org/blog/django-push-using-server-sent-events-and-websocket/) but I haven't managed to decide if I want to go with Django or if I should purpose a new stack of software which is more suitable for the job. Going with Django seems a little bit unnatural. Can any experienced developers point me in the right direction?
So, the basic question is: what are some alternatives to the current software stack I have for building a real time web application?
Thanks
PS: Not a native English speaker. :)
EDIT: The alternatives need to allow secure connections.
EDIT 2: The web applications we develop are games.
Look into http://www.tornadoweb.org/ + http://www.mongodb.org/ + https://github.com/bitly/asyncmongo + http://socket.io/
I think it's a good idea to use that to create real-time application.
You need to weigh your decisions against your goals.
You want a product
Then write your code in the language framework that you are most familiar with, only when you have a product and it has limitations consider switching tools.
You want to learn something new
Try out the new language, framework - but it may take a lot longer to produce a product and you may find that the new tool isn't any better than the old one.
Half and Half
Try starting two projects, and building the same thing in each project, just using the other tool. This will take even longer, but you should be able to see which tool you prefer / is best suited to your task very quickly.
Alternatives
I'm not quite sure what you mean by django is 'unnatural'. Django can do server / client communication - just use some AJAX to talk back to the django server, then call another pythonic library to process the request. Python alternatives to django include the wonderful flask and web.py, though neither will do client / server communication unless you program them too (like django). If you're not into python you might try ruby on rails. For the client side you will need to know something about JavaScript so go and learn up on that (coffescript and jQuery can ease JS pain, but do learn JavaScript first).
Of course you could bite the bullet and go with node.js as the server base, apparently it's pretty good (I've not tried it yet) - and written in JS.
EDIT:
In light of your comments, take a closer look at
django-websockets,
node.js + push server
websockets
Noting also that this question is a potential duplicate.
For the real time web applications I suggest that you go with the websockets, they can be secure and response times are very fast as when connection is made there are no overheads in communication anymore. If you are proficient in python you can make server in python twisted and clients in python and/or javascript using autobahn. P.S. here is a really great tutorial for twisted.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Rails does not need to be restarted after I modify the codes in views and controllers. Do such features also exist in Python web framework?
I tried Flask and Pyramid before. I know they don't need to be restarted if I only changed the template, but have to be restarted if I changed the views(which are similar to controllers in rails). And the restart takes a few seconds to finish.
As I remember, rails doesn't need to be restarted even when I changed codes in controllers. Does anyone have ideas about whether such feature also exists in Python web framework?
Pyramid has an option to automatically restart the server after changing a file:
pserve development.ini --reload
I'm sure each projects documentation provides an anser to your question
Django does as well (which you didn't ask for in your question)
Rails implements development-time reloading as follows. There are two mechanisms at work.
Whenever the code references a class that does not exist, a callback (const_missing) can be called. Rails installs such a callback. In this callback it checks whether there is a corresponding class in one of the application load paths (e.g. in app/models), loads it and carries on. This mechanism is called "Rails autoloading" (not to be confused to Ruby autoloading which is something different).
Rails tracks which classes have been autoloaded. At the end of the request, it removes all those classes from memory.
Obviously this has some limitations. If your code stores stuff in global variables then Rails will not clear them at the end of the request, so if you global variables keep growing you will leak memory during development. Reloading also causes subtle differences in semantics between development in production. Whereas something like
scope :older_than_one_year, where('date < ?', 1.year.ago)
works as intended in development (because the model is reloaded on each request, causing 1.year.ago to be constantly re-evaluated), it doesn't work as intended in production (because the 1.year.ago is only evaluated once, so if your app has been running for a year then that scope actually translates to 2 years ago).
I don't know whether something can be implemented in Python, I'm not familiar with Python's on-the-fly class creation/modification/removal capabilities or whether it has any hooks similar to const_missing.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I'm in that horrible questioning state. I'm trying to decide between Django and Rails.
From what I've read, Django probably fits my needs better, both from a "cultural" and goal point of view. The baked-in admin interface pretty much sells me alone. However, I have one critical concern: it looks like the Rails community is much larger. This could be a plus OR a minus; read on.
I have experience hanging my hat on a technology that does not have as vibrant a commmunity as its "competitor." I run a Mac consulting firm in the Bay Area. Up until very, very recently (like the last year!), finding resources for very difficult issues (especially server- and network-related) was so difficult that it was often not even worth trying. This is now changing rapidly due to the Halo Effect, but if it wasn't for Steve Jobs' return to Apple and the iPhone, the future would look just as bleak as the past.
So, while Django looks awesome, I am concerned about pigeonholing myself in yet another niche. I'm less concerned with my theoretical job prospects as a Django developer (I like my job) than I am with simply having resources available to create and maintain cutting-edge projects that can evolve with the Web, and not lag too far behind.
From the above point of view, it looks like Rails has the advantage. However, here's a problem I've noticed that seems to come from the vibrancy of the Rails community: Want to accomplish a particular Rails programming task you've never done before? Google it; you'll find three to six+ different plugins, each with as many advocates as detractors. How do you decide which to use without spending hours and hours learning and prototyping? How do you know that the one you choose won't be end-of-lifed in 12 months, and you'll have to redo that part of your app in order to stay current with the latest Rails distribution?
My latter point brings me right back to where I started: Django seems like a time-saver. Except now I have two reasons to think so, not just one.
I should mention that I've already spent a significant amount of time learning Ruby and Rails, dabbled a bit in Python, and quite prefer Ruby.
Would love your thoughts.
If the size and the vibrancy of the community is the main problem, than maybe you should look at other framework stacks not just Django and Rails (those two make allot of noise and hype, but there are other much more bigger that don't get that loud - e.g. Java/JVM based framework stacks have users in a few order of magnitude higher than those two you mention).
If the game however is just between these two, when I would decide, I would take in consideration especially the available tools (how good the IDE support is) - at least for me they're very very important, since they're what make a productivity difference.
Even if on the Mac the hype is of course TextMate, with all the respect, that is just an advanced editor - not an IDE with "smart" features like error highlighting in code, smart and correct completion, etc.
The smartest existing IDE for Rails is RubyMine, so considering that for Python (Django) there's nothing not even close that advanced, I would choose Ruby on Rails even for this just only reason. Of course, another plus point for RoR is the bigger number of books available (so when in doubt, I have better chances to find a solution in one of them).
What about Pylons?
From what I have seen neither one looks like it will become a niche any time soon, both have active communities and dedicated developers. Ruby and python are both great languages, and both are being actively developed as well. At some point Django will have to migrate from python 2.x to 3.y, which may be a little bit painful, but the same sort of thing can be expected from rails at some point in the future.
I think you have narrowed it down to the right two for being main stream yet not stagnant. They both have advantages and disadvantages, and if there isn't a clear reason to chose one or the other for your project, I would say go with the language you prefer. Python is my language of choice, so baring some killer reason to chose RoR, Django is the natural way to go to continue developing the way I like to. If you prefer ruby, I would recommend going with RoR unless Django seems to fit your application in a way RoR does not.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
I've been reading up a lot lately on comparisons between Python and a bunch of the more traditional professional languages - C, C++, Java, etc, mainly trying to find out if its as good as those would be for my own purposes. I can't get this thought out of my head that it isn't good for 'real' programming tasks beyond automation and macros.
Anyway, the general idea I got from about two hundred forum threads and blog posts is that for general, non-professional-level progs, scripts, and apps, and as long as it's a single programmer (you) writing it, a given program can be written quicker and more efficiently with Python than it could be with pretty much any other language. But once its big enough to require multiple programmers or more complex than a regular person (read: non-professional) would have any business making, it pretty much becomes instantly inferior to a million other languages.
Is this idea more or less accurate?
(I'm learning Python for my first language and want to be able to make any small app that I want, but I plan on learning C eventually too, because I want to get into driver writing eventually. So I've been trying to research each ones strengths and weaknesses as much as I can.)
Anyway, thanks for any input
An open source project I work on for VCS integration (RabbitVCS) is written entirely in Python/PyGTK and includes:
Two file browser extensions
A text editor extension
A backend VCS status cache running asynchronously, using DBUS for the interface
A fairly comprehensive set of dialogs, including VCS log browsers, a repository browser and a merge wizard (maybe that one isn't such a selling point).
There's no standalone app, but we're thinking about it.
Because we're always adding new features, and currently trying to adapt to new VCS', Python is ideal for the ability to quickly refactor entire layers of code without breaking our mental flow. I've also found that the syntax itself makes a real difference with complicated merging of version controlled branches, but that might come with the ability to read it quickly.
Recently we've begun adding support for a new VCS, requiring:
refactoring current code to separate VCS specific actions and information from common/generic information
refactoring the UI layer to accomodate the new functionality
Most of what we've achieved has been possible because of the availability of C/Python bindings (eg. PySVN, Nautilus-Python, etc). But when it hasn't been available... well, it's not that hard to roll your own (as a developer did for the new VCS). When the bindings lack functionality... it's not that hard to add it.
The real drawbacks so far have been:
Threading mishaps. Lesson learnt: forget about threads, use multiple processes where possible or your toolkit's threading method (eg. PyGTK, wxPython and Twisted all have their own ways of dealing with concurrency)
(C) Extensions. Cause threading mishaps (they almost invariably lock the GIL, preventing threading). See above.
Needing to hack on C bindings when certain functionality is unavailable.
Profiling can be tricky when you're not just doing something based on a single function call.
If you want to know about more specific aspects, ask away in the comments :)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Just like the title asks. I've been learning Python for a while now and I'd say I'm pretty decent with it. I'm looking for a medium or large project to keep me busy for quite a while. Your suggestions are greatly appreciated.
Find a local charitable orgainzation with a lousy web presence. Solve their problem. Help other people. Learn more Python. Everyone wins.
You can invent a game and code it with pygame. They're always fun to code and you still learn a lot when you code a game.
What are you interested in doing? You could write a whole host of database programs, for keeping track of recipes, cd's, contacts, self tests, etc....
Basically make code to load/save to a database and enforce some business rules, then expose it by a web service. Then make both a web front end and an application graphical front end (using TK/WxWidgets/Qt (4.5 will be LGPL YAY)) that talk with the web service.
That should give you practice with creating/talking with web services (something more and more companies are doing) along with both main ways of creating a GUI.
You could try to replicate an application that is impressive to you just for the sake of guessing how it works behind the scene.
If I had to do that, I'd probably try to clone the following webapps using Django:
BaseCamp
dPaste
Reddit
Mint.com
Here at stackoverflow there are already people asking for solutions to their problems:
e.g.: If you are interested in GUI programming: thumbnailctrl
Anything that hasn't been done to death... no need for yet another clone of popular app x
What I like to do is(with my ti 83) instead of doing all my math by hand I like to program my calculator ti di the problem then do the rest of the problems with the new program. It's fun and you get your homework done so you could do this in python for a fun project(s).
Consider something that does the following:
is multi threaded and preferably include need for synchronization
reads/writes data to a remote database (or even local database)
reads from a web service and includes xml parsing
outputs xml/ html
There are a number of example projects you could do, but if you accomplish all the above, then it will surely give sufficient exposure.
If I had the time to code something just for the fun and the experience, I would personally start an open source project for something that people need and which does not already exist.
You can search the Web for a list of missing opensource projects, or you can base it on your own experience (for example, I would personally love to have some way to synchronize my iPhone with thunderbird+lightning : I hear there's a solution through Google Calendars, but I would like a solution without external servers).
I think the best thing you can do now is spend time learning a new technology, preferably including a new programming language.