How to register views with config.add_view()

16 views
Skip to first unread message

Francis Addai

unread,
Jan 12, 2013, 8:29:14 AM1/12/13
to pylons-...@googlegroups.com
Hello all, I am following the pyramid_deform tutorial over here https://pyramid_deform.readthedocs.org/en/latest/. I am really battling out with the FormViews usage to the app's UI.
Can anybody on here give me a crash course on how to use  config.add_view() or an alternative to register my views so that my forms can be rendered?
I guess I am not very clear on how to register views with config.add_view(). Code sample from my views module is shown below:

 
......... 
#@view_config(route_name='new_contact', renderer='shm_crm:templates/contacts/add.pt',)
class ContactEditView(FormView, Layouts):
    schema = ContactSchema()
    buttons = ('Add Contact',)
    form_options = (
        ('formid', 'contact-add-form'),
        ('method', 'POST')
    )
    
    def save_success(self, appstruct):
        context = self.request.context
        context.title = appstruct['firstname']
        
    def appstruct(self):
        pass
 
def includeme(config):
    config.add_view(
        ContactEditView,
        context=Contact,
        name='new_contact',
        permission='edit',
        renderer='shm_crm:templates/contacts/add.pt',
    )

Reply all
Reply to author
Forward
0 new messages