# form default data form.content = { "title": "Test title", "address": {"city": "Houston", "country": "KZ"}, "description": "Context description", } res = form.update_form() if IResponse.providedBy(res): return res return {"view": form} if __name__ == "__main__": from pyramid.config import Configurator from pyramid.scripts.pserve import wsgiref_server_runner from pyramid.session import UnencryptedCookieSessionFactoryConfig config = Configurator( session_factory=UnencryptedCookieSessionFactoryConfig("secret"), settings={"reload_templates": True} ) config.add_route("root", "/") config.include("pform") config.scan(__name__) wsgiref_server_runner(config.make_wsgi_app(), {})
# render form myform.update() return {'view': myform} if __name__ == '__main__': """ ... """ from pyramid.config import Configurator from pyramid.scripts.pserve import wsgiref_server_runner from pyramid.session import UnencryptedCookieSessionFactoryConfig config = Configurator( settings={'sqlalchemy.url': 'sqlite://'}, session_factory=UnencryptedCookieSessionFactoryConfig('secret')) config.include('ptah') config.scan(__name__) config.ptah_init_sql() # create sql tables Base = ptah.get_base() Base.metadata.create_all() config.commit() app = config.make_wsgi_app() wsgiref_server_runner(app, {})