Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created February 9, 2012 19:10
Show Gist options
  • Select an option

  • Save ralphbean/1782150 to your computer and use it in GitHub Desktop.

Select an option

Save ralphbean/1782150 to your computer and use it in GitHub Desktop.
working on pyramid views
# view
@view_config(route_name="user_form", renderer="admin/user.html")
def user_form(request):
w = widgets.UserForm
w.fetch_data(request)
mw = tw2.core.core.request_local()['middleware']
mw.controllers.register(w.req(), 'user_submit')
return {'widget': w}
@view_config(route_name="user_grid", renderer="admin/user.html")
def user_grid(request):
w = widgets.UserGrid.req()
mw = tw2.core.core.request_local()['middleware']
mw.controllers.register(w, 'user_grid')
return {'widget': w}
# widgets
class UserForm(tw2.sqla.DbFormPage):
entity = models.User
#resources = [tw2.core.CSSLink(link='static/css/style.css')]
redirect = '/admin/user/grid'
title = 'User'
class child(tw2.dynforms.CustomisedTableForm):
action = '/tw2_controllers/user_submit'
id = tw2.forms.HiddenField()
username = tw2.forms.TextField(validator=tw2.core.Required)
password = tw2.forms.TextField()
groups = tw2.sqla.DbCheckBoxList(entity=models.Group)
#class cast(tw2.dynforms.GrowingGridLayout):
# character = tw2.forms.TextField()
# actor = tw2.forms.TextField()
class UserGrid(tw2.jqplugins.jqgrid.SQLAjqGridWidget):
id = 'user_grid'
entity = models.User
excluded_columns = ['id', 'password', '_password']
prmFilter = {'stringResult': True, 'searchOnEnter': False}
pager_options = { "search" : False, "refresh" : True, "add" : False }
options = {
'url': '/tw2_controllers/user_grid/',
'rowNum': 15,
'rowList':[15,30,50],
'viewrecords': True,
'imgpath': 'static/jqGrid/themes/green/images',
'width': 'auto',
'height': 'auto',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment