3 ms·
If people don't agree on the IF statement, they just don't agree on it. I find that I can discipline myself enough to use a full IF - having always used the py
by mdasen 17y ago
If people don't agree on the IF statement, they just don't agree on it. I find that I can discipline myself enough to use a full IF - having always used the pyif (http://www.djangosnippets.org/snippets/130/ http://www.djangosnippets.org/snippets/130/) template tag in Django. I don't think this is such a big deal since one can swap out the templating layer in both Django and Rails for something they'd rather. If anyone reading this sees this as a big point, Liquid in Rails offers a more Django-like experience and Cheetah will give you things like full IFs in Python.
You make a good point about not having to copy the code into the project directory and have multiple pieces of code sitting on the server. Someone pointed out that Rails Engines (included in 2.3) allow for this, but I haven't personally used them to know how nicely they work.
For the security concern of auto-routes, this is actually a bigger concern in Python than in Ruby just because of the different ways that they handle OO stuff. In Python, everything is a public method. So, if Django just mapped URLs to methods, there would be no way of hiding a method you didn't want called. Ruby has the ability to make private and protected methods and Rails only makes public methods available as actions (the private and protected ones still being able to be called in their scope).
So, it isn't a great security concern in Rails since it's trivial to define what is public and what isn't. Likewise, if one chooses, you can decide to map all of the URLs explicitly like Django and turn off the default :controller/:action/:id route. So, Rails offers both ways.
Just as a note about Python: Django could just auto-map URLs to any method not starting with an underscore (the convention used in Python to say, this is kinda private even though Python will let you use it). Or there could be a kwarg (keyword argument) in the method signature that Django looked at. Anyway, there are ways around the fact that the Python language doesn't have explicitly private methods. Django's convention (like Python's) is just that explicit is better.
- ubernostrum 17y ago"If people don't agree on the IF statement, they just don't agree on it." Pretty much. And while individual cases can be argued, I think the general goal of keeping program logic out of templates is a good one. "For the security concern of auto-routes, this is actually a bigger concern in Python than in Ruby just because of the different ways that they handle OO stuff. In Python, everything is a public method. So, if Django just mapped URLs to methods, there would be no way of hiding a method you didn't want called." Actually, what I'm thinking of is a case where you might have a single application running on multiple sites, and -- for security reasons -- there'd be some views that you wouldn't want exposed on one or more of those sites. Forgetting to "un-map" even a single URL could lead to major problems (and, since an auto-mapping system can, in theory, locate anything that's on the import path, the risk seems to me to be a bit too much to accept just for the convenience of occasional automatic URLs).