Author |
Message |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Mon Mar 31, 2008 12:20 pm |
|
Holy crap!
You model your database tables by creating a python class for each table. From each class Django automatically creates the correct SQL for your backend database (e.g. CREATE TABLE). It also generates a Python API to your table. In other words, you never need to write SQL ever again. Update the database by manipulating a python object. Sweet!
You also get, for free, an admin interface to your apps! No need to write an interface to let admins add and update content. Again, it just looks at your model to figure out how to do this.
It uses a template system to separate display from application code.
I'm 1/2 way into the 2nd tutorial and I'm sold. From what I've seen so far, it is not as beginner friendly or general purpose as PHP-Nuke (you need to be a python programmer to setup your site), but wow does it look powerful and cool if you are a web developer.
I was trying to convert a friends static HTML site into OO PHP 5. I might give it a go with Django instead.
http://www.djangoproject.com/
(BTW I'm new to python, but I like what I see so far. I wrote an IRC "bot" in python that sits in our server's IRC channel and watches who comes and goes. It updates a MySQL database so my RavenNuke site can display who is in the channel in a block. I leveraged a python IRC and MySQL library. Once I figured out how to use those 2 libraries, it was a snap to make the bot. Fun stuff!) |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
jakec
Site Admin

Joined: Feb 06, 2006
Posts: 3048
Location: United Kingdom
|
Posted:
Mon Mar 31, 2008 12:52 pm |
|
|
|
 |
evaders99
Former Moderator in Good Standing

Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Mon Mar 31, 2008 3:12 pm |
|
Better than Code Igniter or Ruby on Rails? |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
 |
Gremmie

|
Posted:
Mon Mar 31, 2008 3:39 pm |
|
Don't know as I haven't looked at too many frameworks in detail. I have studied Zend and Code Igniter a little bit. Like those you mention, Django is just a framework, one could use it to build a CMS like Nuke, Drupal, Joomla, etc.
It is being used on real world sites and claims to be able to handle load. Ruby on Rails has been criticized for being too slow, but I don't know enough to say either way. Python probably has more miles on it than Ruby and has been optimized more. But again I dunno. It sure looks neat.
Here is a whole book on it, available for free online:
http://www.djangobook.com/ |
|
|
|
 |
djmaze
Subject Matter Expert

Joined: May 15, 2004
Posts: 727
Location: http://tinyurl.com/5z8dmv
|
Posted:
Wed Apr 02, 2008 4:23 pm |
|
CRUD designs suck, you ever needed a UNION or JOIN's ? |
|
|
|
 |
Gremmie

|
Posted:
Wed Apr 02, 2008 5:01 pm |
|
Django creates intermediate join tables for you when you indicate a table has foreign keys. They do not preclude you from writing your own SQL by hand, they just make it easy for you to avoid it in the common cases.
Another cool thing that they can derive from your python classes that represent your database table is automatic form generation and validation.
I'm approaching this with a cautious eye, but so far I like what I see. I'm working through the tutorial and hope to cut over a small static html site to it when I get some time. |
|
|
|
 |
djmaze

|
Posted:
Thu Apr 03, 2008 11:04 am |
|
Now we're talking.
I disliked starting to learn "ruby on rails" because of the massive CRUD floating around.
I'm a die-hard that uses union, (inner|outer|left|right) join, views, triggers, procedures and who knows what else a RDBM provides me.
MyISAM (not a rdbm!) just sucks because i can't use them, but on the other hand i can build fast websites with it that accommodate some people their needs.
But then you don't want a massive framework that eats CPU and classes just to show a page either.
Problem with all the RDBM features is that it is hard to write automatic CRUD style frameworks for the ease of things.
But maybe i just create to advanced websites to ever need the ease of use you people want. |
|
|
|
 |
Gremmie

|
Posted:
Thu Apr 03, 2008 11:20 am |
|
I hear ya, I usually like to be in total control myself and despise bloat ware. But this thing really, really saves you from writing lots of tedious code. It is quite amazing. The fact that they can build a complete admin interface for you to allow editors to enter/update content, and do this only from your Python classes that represent your tables is quite stunning. Now I totally see the power of introspection. PHP 5 has similar capabilities in this area also.
I believe in using the right tool for the right job and I can certainly see using something like this to bang out a blog or website for a friend in a weekend. But the developers use this framework to power several newspaper sites so it can apparently scale up.
Anyway I'm going to try to convert a friends website to it hopefully this weekend. Setting up Apache with mod_python may be a bit tricky (for me) but we'll see. |
|
|
|
 |
gotcha
Regular


Joined: Mar 14, 2005
Posts: 91
|
Posted:
Thu Apr 03, 2008 12:24 pm |
|
Sounds alot like cakePHP - http://cakephp.org/
I've been messing with it a bit and I can say that the joins can be quite taxing, but once you go through and optimize everything it is not so bad. Turn on the built in caching and your in business. But for smaller apps, the overhead probably isn't worth it. It is kinda fun to work with as you just create the table structure, type in a couple of commands in the terminal, answer a few questions, and all the sudden you have all the basic code in place to list/add/edit/delete/view. |
|
|
|
 |
Gremmie

|
Posted:
Sun Apr 06, 2008 5:32 pm |
|
I spent many many hours this weekend with Django. I didn't finish converting my friend's website for him like I imagined, mainly because of the learning curve for both Django and Python. However, I have built several apps for his site, and it is quite amazing. Once you define your database tables in python, you pull a lever and it creates the tables for you as well as an admin interface to immediately begin adding data. Sprinkle some metadata in your python classes and you can very quickly build a powerful admin interface that includes support for searching, editing, filtering, and even seamlessly handles editing objects as part of other objects when you have one to many or many to many database relationships. In fact, I spent most of my time learning how to do this part and just playing with it.
Django, like lots of other frameworks, strongly supports a separation of coding from view; the so called MVC paradigm. Django calls it the MTV (model-template-view). I really really like this. When I am coding the "view" all I do is concentrate on obtaining the data for display. And using their database API is a breeze. Instead of writing SQL you just chaing together calls on a python object manager for your table:
news = News.objects.order_by('-date')[:10]
obtains the last 10 news posts in reverse date order (date in this case is a column in the table).
You then pass your news variable to a template .html file which has a very small mini language for looping over the news objects and displaying them. When you build the template all you have to think about is how to display it. In PHP-Nuke of course, 99% of the time your display and business logic is totally mixed up together.
Their template system is optional, you could use another one, or even choose not to use it at all (like what we do in Nuke), but it is pretty powerful. It features template inheritance, so you can flesh out what the whole page is going to look like in one template, leaving "holes" for more specific pages to fill in. The holes can have defaults too in case no one fills them in.
It comes with a development server so you don't have to even setup a web server to try it out. However it was very easy to add mod_python to my XAMPP install and use it that way.
I wish I could stay home this week from work and finish this. It is really cool. I'm really impressed. |
|
|
|
 |
kguske
Site Admin

Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Sun Apr 06, 2008 6:41 pm |
|
Last week, I saw some interesting discussions about various frameworks, including CakePHP, CodeIgniter, Symfony and Zend:
http://www.phpit.net/article/ten-different-php-frameworks/
http://snook.ca/archives/php/zend_framework_first_impressions/
http://www.dustinweber.com/web-development/cakephp/the-best-php-framework-is-symfony-really-it/
http://2tbsp.com/node/87
Several comments suggest that, at this point, Zend Framework, is more a library of code, than a framework. Of course, since I already use SimplePie, I'm predisposed to use Cake...  |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
 |
Gremmie

|
Posted:
Sun Apr 06, 2008 7:21 pm |
|
Cool, more interesting things to read about! |
|
|
|
 |
Gremmie

|
Posted:
Thu Apr 24, 2008 8:17 pm |
|
|
|
 |
Gremmie

|
Posted:
Tue May 27, 2008 7:01 am |
|
I got the site up and running, which was a tad more difficult than a typical PHP site. I'm very happy with it.
Another very cool thing is that it seamlessly integrates with Only registered users can see links on this board! Get registered or login!. Once I got memcached built on my server and python bindings for it, the site SCREAMED. I just had to add a couple of lines in my config file, no code changes on my part. I wish Nuke had something like this. |
|
|
|
 |
kguske

|
Posted:
Tue May 27, 2008 10:41 am |
|
There have been several approaches to integrating various cache functions with Nuke. There is sure to be plenty of discussion in the forums here on that subject... |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Tue May 27, 2008 5:42 pm |
|
Yeah, the Zend Framework even has some caching, but, admitidly, I have not looked at very carefully (just saw that they have something - lol). I've had to convert over a Blogger site to b2evolution and found the ZF invaluable. Made my job 100 times easier. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
Gremmie

|
Posted:
Thu Sep 04, 2008 11:10 am |
|
Well Django just released version 1.0 after 3 years of development!
http://www.djangoproject.com/weblog/2008/sep/03/1/
I urge you guys to check this out. Download the code and try out the tutorial. It even comes with a mini development server so you don't need to futz with XAMPP or Apache to try it out.
For support there is a wiki, an active google group, a very helpful IRC channel, and a (mostly) weekly podcast. It is really an amazing system. |
|
|
|
 |
|