Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

Showing posts with label mvc. Show all posts
Showing posts with label mvc. Show all posts

Yet another Framwork: Pylons

Pylons combines the very best ideas from the worlds of Ruby, Python and Perl, providing a structured but extremely flexible Python web framework. It's also one of the first projects to leverage the emerging WSGI standard, which allows extensive re-use and flexibility — but only if you need it. Out of the box, Pylons aims to make web development fast, flexible and easy

Looks like a fun language, after reading the Pylon book for a few days now, it looks very interesting.

This framework is based on Paste and allows some extended python usage, templating, modeling and basically a full MVC application development interface (even CouchDB).

What i can say about it, is that it's some kind of another Rails-ish framwork ("paster" for "generate" for example), these frameworks are popping like mushrooms these days (Currently reviewing the PHP Akelos framework as well)

The pylons web site offers general information, a link to the online book and some screencasts.

The Boolean connection

Few people understand the true mentality of dealing with a Boolean variable.
The normal programmer will panic, and immediately attempt to compare it to a Boolean constant.

when using Rails, This is wrong.

When migrating a boolean typed column using Rails, the actual column type created is "tinyint(1)" (a single digit number presentation which means that the actual value being saved is 0's or 1's.
Where is the problem? in Ruby for a change.
In Ruby, everything except nil and false is considered to a true value. In C, Python and many other languages, 0 and possibly other values, such as empty lists, are considered as false.

which brings us to the inevitable conclusion, that simplay comparing boolean values to true or false will not do.

Rails solves this tiny issue for us, for each boolean attribute, Rails implements a "query method" as i prefer to call them. These query methods are simply called by issuing the boolean attribute name with a "?" suffix.

for example, the @mail_message instance object has a is_important boolean attribute, so instead of doing:


@mail_message.is_important == true

or whatever, we can simply ask rails by:

@mail_message.is_important?


beautiful... isn't it?


The Web Ask eizesus.com

Subscribe

    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.

    Labels