Thoughts from a newbie: -1 for @view, alternative way to introduce
"view" in the TG terminology. Explanations below.
Kevin Dangoor wrote:
> The view for a given request is really represented by the @expose decorator.
Hmmm... is it really so? Take this pretty common web development
pattern: to prevent multiple form submission by a user reloading the
results page, a form submits to a submission script (logic only), that
then does a redirect to a results page (view). From my newbie
perspective, if the decorator was called @view, here is how I would have
coded this on my first try:
def saveFoo(self, *args, **kw):
# Logic to save foo here...
# ...
raise turbogears.redirect('/results')
@view(template='foo.templates.results')
def results(self):
return "Thank you!"
Of course that would not work... but then I'd have to ask: why do I need
the @view decorator on the saveFoo() method, since in the MVC sense,
this method does not have a view? On the other hand, I find @expose much
easier to grasp, since it simply says what it actually does: expose the
method to the outside.
So, even if we keep @expose for compatibility, simply calling the
decorator @view, and in particular marketing it as "@view" in the
documentation, would have caused me some unnecessary newbie frustration.
So I say let's call a duck a duck: -1 for @view, +1 for @expose.
Now, if we want to introduce "view" in the TG terminology, my
understanding (again newbie alert, please correct me if I am out to
lunch ^^; ) is that it is the templates that represent the "V" in MVC.
So how about renaming the "template" argument of the expose decorator to
"view", along with the "templates" folder to "views":
@expose(view='foo.views.results')
Yes that would probably be a more involved changed. But again, I do not
think @view is a good idea. So what do you think?
Cheers,
--
Yves-Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---