Does anyone have experience using Python in different variaty of applications?
A little background - I am a 3D artist in an animation studio. I do programming in PHP and use Zend framework for my personal project. Python has always been a language I wanted to learn because it can be used within many applications our studio is using (3D MAX, MAYA to name a few) My supervisor knew about my web background and wanted me to create a web base time line manager for the company. From the requirement I'm expecting quite a simple backend ... so it might be a good opportunity to finally learn Python. The bulk of the work will be on AJAX for the interactive front end.
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
a little curious about Django features as well. How well does the framework cover in terms of web application compare to Zend? Our application is pretty basic in the back end and I would love to know if Django will be able to cover them.
authenticate against Windows active directory
quick database update via AJAX interaction (drag and drop time line mostly)
Other basic stuff like discussion forum and directory browsing/file manager
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
No
authenticate against Windows active directory
Yes. You may need to customize an Authentication Backend.
quick database update via AJAX interaction (drag and drop time line mostly)
Django has nothing to do with Ajax. Use piston to create pleasant RESTful API that Ajax can use.
Other basic stuff like discussion forum and directory browsing/file manager
There are many, many canned applications for Django that you can plug in and integrate.
I love python as a language - but it's not the answer to everything. I know this is throwing mud in a python group, but python has one serious limitation - the rigid source code format.
While going through a django tutorial - I noticed that you cannot insert python source code into a template, and that this was presented as a 'feature' for separating programmers and designers.
I later realized that it's a limitation of django - and any other environment where python source code might get accidentally mangled. This also includes HTML WYSIWIG editors and database based 'manglers' (like Drupal).
In my opinion it's a very serious limitation with no easy cure - especially with the need to use other tools to manage the complexity of HTML / CSS / JavaScript.
I found Django a really good way to learn python. There's very little that's quirky, magical or un-pythonic in the framework. A bit of setup and you're away, writing standard python code.
Related
I've been learning python for use in ArcGIS and some other non-web applications. However, now that I've taken on building a personal website I am interested in using it for web development (as it is the only scripting language I currently know).
I've noticed that there are a lot of these things called "frameworks", such as Django. From what I understand they are just a collection of packages to save you from re-inventing the wheel but I don't really know how they work.
Furthermore, I do not like GUIs, if I need a framework I would like to find one that could be used through a terminal, starts out simple and can be scaled for more complexity when I'm ready. Any advice or ideas on frameworks and why I would want to use one?
The Python web frameworks have nothing to do with GUIs, and can all be used via the terminal.
The benefits of a framework, as you say, are all to do with making your life easier by supplying the components you need to build a website: the main ones are database interaction through an ORM, a templating system, and URL routing. On top of that, the big frameworks also included optional extras like user authentication, administration interface, and so on.
Personally I like Django, but your mileage may vary: I would say, though, that whatever you do with Python and the web will require some sort of framework, even if it's one of the absolute minimal ones like Flask which basically do just the routing part. There's simply no point in writing all this stuff from scratch when it's been done for you.
I'd second the post above: Django is a great framework and will save you loads of time in the long run.
Pretty much every challenge you'll come across when writing a web application will already have been solved, e.g. How do I send emails? What about an admin interface to edit the data? User security?
In my view picking the best framework is all about the ecosystem around that framework. How well used is it? Is it discussed widely on the internet? Have others encountered, and solved, the problems I'm facing?
In terms of where you start, see the Django Tutorial here:
http://docs.djangoproject.com/en/1.2/intro/tutorial01/
If you think Django offers you too much, I'd recommend that you take a look at CherryPy just to compare the different, and much simpler, approach.
With Python, you've got lots of options. To start, I would recommend looking here -- it explains the basics and provides a fairly complete list of frameworks.
If you're looking for something that starts out simple but can also handle more complexity, then you should take a look at web2py. It requires no installation or configuration, has no dependencies, and includes a web server and a relational database. It also includes an optional web-based integrated development environment and admin interface, but you can work through the terminal instead if you prefer.
It's very easy to learn and was designed for ease of use, faster development, and security. You can get a lot done with very little code thanks to the included scaffolding app along with many sensible default behaviors. As things get more complex, web2py can handle it, as it is a well-integrated full-stack framework with lots of built-in functionality, including a database abstraction layer, form handling and validation, access control, web services, and easy Ajax integration.
Personnally, I don't use any framework, I write either from scratch on BaseHTTPServer, or using WSGI (with mod_wsgi).
It is a bit long to write the skeleton, but I think it is faster (I mean at runtime), there is less constraints, and there is lesser to learn.
I would like to design a web based game preferably in Python ( using Django maybe) though I'm open to any language other than Java/Flash/ActionScript. The idea I have in mind is more about data models than graphics and will leverage social networking sites. I would like to extend it with a mobile web interface in the future. Please give your invaluable suggestions and recommend some resources with which I can get started.
Step 1. Design a good game.
Step 2. Be sure that it fits the HTTP model of simple request/reply GET/POST processing. Be sure that the game is still good. Some people try to do "real time" or "push" or other things that don't fit the model well and require lots of sophisticated GUI on the desktop.
Step 3. Find a web framework. Django is okay. Others are good too.
Learn the web framework. Don't start with your game. Start with the tutorials.
Step 4. Rethink your game. Be sure that it fits the framework's model, as well as the HTTP model. Be sure that the game is still good. In particular, if your focus is "more about data models than graphics" then you have to really be sure that your game's data model fits your framework's capabilities.
Step 5. Rethink your framework. Is Django still the right choice? Perhaps you need to go back to step 3 and learn another framework. There's nothing wrong with learning a second framework. Indeed, until you learn another framework, you won't fully get Django.
Step 6. Now you should have enough background to actually implement your game.
If you are considering using Django as your framework, here are just some basic points about it you might find helpful to consider:
Firstly, the Django libraries are written in Python. Therefore, at least a basic knowledge of python is required to develop a site using Django.
Secondly, Django includes its own template system that is useful for integrating with html - http://docs.djangoproject.com/en/dev/topics/templates/ .
Thridly, as you've stated that you are more concerned with data models (which I am assuming means you are going to want to store information in some way especially considering it is related to social networking ?) Django also provides for a way to integrate with databases like MySQL and SQLite and the tutorial even walks you through how to set one up if you haven't already - http://www.djangobook.com/en/2.0/chapter05/ - and how to integrate with a legacy database if you have - http://docs.djangoproject.com/en/dev/howto/legacy-databases/?from=olddocs .
Lastly, Django enables you to run your site off of their development server which can be really useful for testing and running your site locally before deploying it to the web via Apache or another web server of your choosing - http://docs.djangoproject.com/en/dev/intro/tutorial01/#the-development-server .
I would really encourage you to do the online tutorial - http://docs.djangoproject.com/en/dev/intro/ - or take a look at Holovaty and Moss's "The Definitive Guide To Django" (available on http://www.djangobook.com/).
Hope this helps!
I'm tasked to create a simple CRUD MVC application, and I thought it's a good opportunity to learn python. Because of its great documentation, I'm thinking now that I'll go with Django.
Now, this simple CRUD MVC application could become quite complicated in the future. I might have receive and issue JMS messages, display charts that are updated periodically (I'm thinking about ajax) and what not.
Given this I'm a little worried, since while I'm told it's easy to call Java code from python (I'm a Java developer), I'm also told that Django is generally best for content based web application, and can be restrictive.
Do you think it is okay to go with Django in this case?
simple CRUD MVC application
Django does this "out of the box" The admin interface is a simple, CRUD, MVC application. You don't do much programming to make this happen. You create the model. That's it. Use the Django admin for your CRUD application. Done.
I might have receive and issue JMS messages, display charts that are updated periodically (I'm thinking about ajax) and what not.
That's the point. Since you didn't waste time writing the CRUD application, you are able to write the other, more interesting stuff.
Look at http://hjb.python-hosting.com/ for a Python-JMS bridge.
We have FLEX front-end and Django-based RESTful web services. The Django apps create PDF's, and other things. The FLEX does pretty pictures and charts.
Django is generally best for content based web application, and can be restrictive.
Doesn't mean anything. Provide a quote or a link to whatever it is you're talking about.
Mozilla is currently rewriting two of our largest sites on Django. These are both fairly complex applications that interact with numerous online and offline services. With Python's large collection of libraries, anything Django doesn't do itself we've usually been able to find, or create pretty easily. For example, we have both cron jobs and on-demand offline tasks, backed by AMQP, which is similar to JMS.
Short answer: you can get pretty darn complicated if that's what you need to do, and odds are there's already a Python project or library to do what you need.
I'm really interested in learning Python for web development. Can anyone point me in the right direction? I've been looking at stuff on Google, but haven't really found anything that shows proper documentation and how to get started. Any recommended frameworks? Tutorials?
I've been doing PHP for 5 years now, so I just want to try something new.
Django is probably the best starting point. It's got great documentation and an easy tutorial (at http://djangoproject.com/) and a free online book too (http://www.djangobook.com/).
Web Server Gateway Interface
About
http://www.wsgi.org/en/latest/index.html
http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
Tutorials
http://webpython.codepoint.net/wsgi_tutorial
http://lucumr.pocoo.org/2007/5/21/getting-started-with-wsgi/
http://archimedeanco.com/wsgi-tutorial/
There are three major parts to python web frameworks, in my experience. From the front to back:
Views/Templates: Application frameworks don't function as independent scripts - instead, you map paths to python functions or objects which return html. To generate the html you probably need templates (aka views). Check out Cheetah.
Application framework/Server: There are plenty. CherryPy is my favorite, and is good for understanding how a python application server works because a) it's simple and b) unlike django and others, it is just the application server and doesn't include a templating engine or a database abstraction layer.
Database layer: I've actually never used it, but everyone seems to like SQLAlchemy. I prefer, in simple applications, executing SQL directly using a tool like psycopg2 (for postgres).
You can try Django. It's easy to learn, and it works with GAE (though the default version is 0.96, a little bit old, but you can change it). And there's a video about rapid development (by Guido Van Rossum) that goes through the basics of setting up a Django project in App Engine.
I'm just starting out with Python and have practiced so far in the IDLE interface. Now I'd like to configure Python with MAMP so I can start creating really basic webapps — using Python inside HTML, or well, vice-versa. (I'm assuming HTML is allowed in Python, just like PHP? If not, are there any modules/template engines for that?)
What modules do I need to install to run .py from my localhost? Googling a bit, it seems there're various methods — mod_python, FastCGI etc.. which one should I use and how to install it with MAMP Pro 1.8.2?
Many thanks
I think probably the easiest way for you to get started is to work with something like Django. It's a top-to-bottom web development stack which provides you with everything you need to develop and run a backend server. Things can be very simple in that world, no need to mess around with mod_python or FastCGI unless you really have the need.
It's also nice because it conforms to WSGI, which is a Python standard which allows you to plug together unrelated bits of reusable code to add specific functionality to your web app when needed (say for example on-the-fly gzip compression, or OpenID authentication). Once you have outgrown the default Django stack, or want to change something specific you can go down this road if you want.
Those are a few pointers to get you started. You could also look at other alternative frameworks such as TurboGears or paste if you wanted but Django is a great way to get something up and running quickly. Anyway, I'm sure you'll enjoy the experience: WSGI makes it a real joy knocking up web apps with the wealth of Python code you'll find on the web.
[edit: you may find it helpful to browse some of the may Django related questions here on stack-overflow if you run into problems]
You asked whether HTML is allowed within Python, which indicates that you still think too much in PHP terms about it. Contrary to PHP, Python was not designed to create dynamic web-pages. Instead, it was designed as a stand-alone, general-purpose programming language. Therefore you will not be able to put HTML into Python. There are some templating libraries which allow you to go the other way around, somewhat, but that's a completely different issue.
With things like Django or TurboGears or all the other web-frameworks, you essentially set up a small, stand-alone web-server (which comes bundled with the framework so you don't have to do anything), tell the server which function should handle what URL and then write those functions. In the simplest case, each URL you specify has its own function.
That 'handler function' (or 'view function' in Django terminology) receives a request object in which interesting info about the just-received request is contained. It then does whatever processing is required (a DB query for example). Finally, it produces some output, which is returned to the client. A typical way to get the output is to have some data passed to a template where it is rendered together with some HTML.
So, the HTML is separated in a template (in the typical case) and is not in the Python code.
About Python 3: I think you will find that the vast majority of all Python development going on in the world is still with Python 2.*. As others have pointed out here, Python 3 is just coming out, most of the good stuff is not available for it yet, and you shouldn't be bothered about that.
My advise: Grab yourself Python 2.6 and Django 1.1 and dive in. It's fun.
Django is definitely not the easiest way.
check out pylons. http://pylonshq.com/
also check sqlalchemy for sql related stuff. Very cool library.
On the other hand, you can always start with something very simple like mako for templating. http://www.makotemplates.org/