watsonpy / watson-framework

A Python 3 web app framework.
BSD 3-Clause "New" or "Revised" License
104 stars 12 forks source link

from watson.framework.views.decorators import view // this is whey how need to look? #15

Closed krystian566 closed 9 years ago

krystian566 commented 9 years ago

When i write is work: from watson.framework.views.decorators import view We really need this why just only write this: from watson.framework import views

simoncoulton commented 9 years ago

Realistically you're only going to want to use those decorators when you're wanting to override the template completely (instead of following the existing naming convention) e.g.

from watson.framework.views.decorators import view

class MyClass(object):
    @view(template='something/test')  # which lives in your view folder
    def some_action(self):
        pass

or the response format

class MyClass(object):
    @view(format='json')
    def some_action(self):
        return {'some': 'dict'}  # then outputted as JSON to the browser
krystian566 commented 9 years ago

Correct. I have long break. This men thx you. I need to answer faster.