本文整理汇总了Python中pyramid.config.Configurator.add_jsonrpc_endpoint方法的典型用法代码示例。如果您正苦于以下问题:Python Configurator.add_jsonrpc_endpoint方法的具体用法?Python Configurator.add_jsonrpc_endpoint怎么用?Python Configurator.add_jsonrpc_endpoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.config.Configurator
的用法示例。
在下文中一共展示了Configurator.add_jsonrpc_endpoint方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
"""
Session
"""
session_factory = SignedCookieSessionFactory('xadminSessionToken')
config.set_session_factory(session_factory)
"""
MongoDB conn
"""
mongourl = settings['mongodb.conn']
mongodbn = settings['mongodb.name']
dbconn = Connection(mongourl)
dbhdl = dbconn[mongodbn]
# add mongo ming session handler to every request object.
def add_mongokit(event):
req = event.request
# add (dbconn, db) to request object
req.dbconn = dbconn
req.db = dbhdl
config.add_subscriber(add_mongokit, NewRequest)
# static files
config.add_static_view('static', 'static', cache_max_age=3600)
authn_policy = AuthTktAuthenticationPolicy(
settings['xadmin.secret'], callback=groupfinder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
# jsonrpc
config.include('pyramid_rpc.jsonrpc')
config.add_jsonrpc_endpoint('dealerApi', '/dealerApi')
#
# applications
#
def addApp(package):
# load subpackage url dispatch
import importlib
subpkgurls = package + '.urls'
urlpatterns = importlib.import_module(subpkgurls).urlpatterns
print(urlpatterns)
for i in range(len(urlpatterns)):
config.add_route(urlpatterns[i][0], urlpatterns[i][1])
# scan subpackage view
config.scan(package)
# register apps
addApp('xadmin.dealerAdmin')
return config.make_wsgi_app()
示例2: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_conf, **settings):
config = Configurator(settings=settings)
config.include('pyramid_rpc.jsonrpc')
# add a JSON-RPC Endpoint
config.add_jsonrpc_endpoint('api', '/api')
##config.add_renderer('jsonp', JSONP(param_name='callback', indent=4))
config.scan(__name__)
return config.make_wsgi_app()
示例3: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
init_model()
############################################################################
#json_renderer = JSON()
#json_renderer.add_adapter(datetime.datetime, lambda v: v.isoformat())
###########################################################################
session_factory = session_factory_from_settings(settings)
if 'localization' not in settings:
settings['localization'] = 'id_ID.UTF-8'
locale.setlocale(locale.LC_ALL, settings['localization'])
if 'timezone' not in settings:
settings['timezone'] = DefaultTimeZone
config = Configurator(settings=settings,
root_factory='ipbb.models.RootFactory',
session_factory=session_factory)
config.include('pyramid_beaker')
config.include('pyramid_chameleon')
############################################################################
config.include('pyramid_rpc.jsonrpc') # JSON RPC
#config.add_renderer('json', json_renderer)
############################################################################
authn_policy = AuthTktAuthenticationPolicy('sosecret',
callback=group_finder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.add_request_method(get_user, 'user', reify=True)
config.add_request_method(get_title, 'title', reify=True)
config.add_notfound_view(RemoveSlashNotFoundViewFactory())
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view('deform_static', 'deform:static')
config.add_renderer('csv', '.tools.CSVRenderer')
routes = DBSession.query(Route.kode, Route.path, Route.nama).all()
for route in routes:
config.add_route(route.kode, route.path)
if route.nama:
titles[route.kode] = ' - '.join([main_title, route.nama])
config.add_jsonrpc_endpoint('pbb', '/pbb') #, default_renderer="json")
config.scan()
return config.make_wsgi_app()
示例4: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(root_factory=Root, settings=settings)
config.add_renderer('.jinja2', pyramid_jinja2.Jinja2Renderer)
config.add_view(views.my_view,
context=Root,
renderer='mytemplate.jinja2')
config.add_static_view(name='static', path=os.path.join(__here__, 'static'))
config.include('pyramid_rpc.jsonrpc')
config.add_jsonrpc_endpoint('echoservice', '/echo')
config.scan()
return config.make_wsgi_app()
示例5: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
config = Configurator(settings=settings)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/')
config.add_route('addpost', '/addpost')
config.include('pyramid_rpc.jsonrpc')
config.add_jsonrpc_endpoint('api', '/api/')
config.include('apex')
config.scan()
return config.make_wsgi_app()
示例6: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
set_cache_regions_from_settings(settings)
config = Configurator(settings=settings)
config.include(jsonrpc)
config.add_renderer('ddjson', DDJSONRenderer)
config.registry.settings['mongodb.connector'] = DDMongoConnector(settings['mongodb.uri'], settings['mongodb.db'], settings['mongodb.users'])
if settings.get('mongodb_log.uri', None) is not None:
config.registry.settings['logdb.connector'] = MongoConnector(settings['mongodb_log.uri'], settings['mongodb_log.db'])
config.registry.settings['redis.connector'] = DDRedisConnector(settings['redis.host'], settings['redis.port'], settings['redis.db'], password=settings.get('redis.pass', None))
config.include('pyramid_sockjs')
#config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('home', '/app/')
config.add_jsonrpc_endpoint('api', '/app/api/', default_renderer='ddjson')
config.add_sockjs_route(prefix='/__sockjs__', session=DDSockJSSession, sockjs_cdn='https://beta.datadealer.com/sockjs-0.3.4.min.js', cookie_needed=False)
config.scan()
return config.make_wsgi_app()
示例7: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
settings['mail.port'] = settings.get('mail_port', None) and int(settings['mail.port']) or 25
globalreg = getGlobalSiteManager()
set_cache_regions_from_settings(settings)
config = Configurator(registry=globalreg)
config.include('pyramid_zcml')
config.load_zcml('workflow.zcml')
config.add_translation_dirs('penelope.core:locale')
from penelope.core.views import PORRequest
config.setup_registry(settings=settings,
request_factory=PORRequest,
root_factory='penelope.core.views.DefaultContext')
# por security
from penelope.core import security
authentication_policy = RepozeWho1AuthenticationPolicy(identifier_name="auth_tkt",callback=security.rolefinder)
config._set_authentication_policy(authentication_policy)
authorization_policy = ACLAuthorizationPolicy()
config._set_authorization_policy(authorization_policy)
config.scan('penelope.core.security.views')
config.include('penelope.core.security.openid2')
config.include('velruse.store.memstore')
config.add_view('penelope.core.security.views.forbidden', renderer='skin', context="pyramid.httpexceptions.HTTPForbidden")
#mailier
config.include('pyramid_mailer')
# penelope.core.models's configuration
config.include('penelope.core.models')
import penelope.core.events; penelope.core.events
import penelope.core.breadcrumbs; penelope.core.breadcrumbs
import penelope.core.sidebar; penelope.core.sidebar
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
config.add_static_view('static', 'penelope.core:static')
config.scan('penelope.core.views')
config.add_route('socketio', 'socket.io/*remaining')
config.scan('penelope.core.socketspace')
config.add_route('tp', '/tp/*traverse', factory='penelope.core.tp.TPContext')
config.scan('penelope.core.tp')
config.scan('penelope.core.smartadd')
config.scan('penelope.core.backlog')
config.add_route('administrator', '/manage', factory='penelope.core.manage.ManageContext')
config.add_route('manage_svn_authz', '/manage/svn_authz', factory='penelope.core.manage.ManageContext')
config.add_route('manage_costs', '/manage/costs', factory='penelope.core.manage.ManageContext')
config.scan('penelope.core.manage')
config.add_route('search', '/search')
config.scan('penelope.core.search')
config.add_route('reports', '/reports/*traverse', factory='penelope.core.reports.ReportContext')
config.scan('penelope.core.reports')
config.add_renderer(name='xls_report', factory='penelope.core.renderers.XLSReportRenderer')
config.add_renderer(name='csv_report', factory='penelope.core.renderers.CSVReportRenderer')
config.include('pyramid_rpc.jsonrpc')
config.add_jsonrpc_endpoint('DashboardAPI', '/apis/json/dashboard')
config.scan('penelope.core.api')
config.add_renderer('skin', renderer_factory)
config.include('pyramid_skins')
config.register_path("penelope.core:skins", discovery=DISCOVERY)
# penelope.core.gdata configuration
config.include('penelope.core.gdata')
# pyramid_formalchemy's configuration
config.include('pyramid_formalchemy')
config.include('fa.bootstrap')
config.include('deform_bootstrap')
config.formalchemy_admin('admin',
package='penelope.core',
factory='penelope.core.forms.CrudModels',
models='penelope.core.models',
view='penelope.core.forms.ModelView',
session_factory='penelope.core.models.DBSession')
config.add_view(context='pyramid_formalchemy.resources.ModelListing',
renderer='fa.bootstrap:templates/admin/new.pt',
request_method='POST',
route_name='admin',
request_type='penelope.core.interfaces.IPorRequest',
view='penelope.core.forms.security_create')
config.add_static_view('deform_static', 'deform:static')
config.add_route('navbar', '/navbar')
config.add_route('favicon', '/favicon.ico')
config.add_route('inbound_email', '/inbound_email')
config.scan('penelope.core.notifications')
from penelope.core.forms import include_forms
#.........这里部分代码省略.........
示例8: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
init_model()
if 'sipkd_sqlalchemy.url' in settings and settings['sipkd_sqlalchemy.url']:
from models.sipkd import SipkdDBSession, SipkdBase
engineSipkd = engine_from_config(settings, 'sipkd_sqlalchemy.')
SipkdDBSession.configure(bind=engineSipkd)
SipkdBase.metadata.bind = engineSipkd
#added 09-08-2016
if 'pdl_sqlalchemy.url' in settings and settings['pdl_sqlalchemy.url']:
from models.pdl import PdlDBSession, PdlBase
enginePdl = engine_from_config(settings, 'pdl_sqlalchemy.')
PdlDBSession.configure(bind=enginePdl)
PdlBase.metadata.bind = enginePdl
session_factory = session_factory_from_settings(settings)
if 'localization' not in settings:
settings['localization'] = 'id_ID.UTF-8'
locale.setlocale(locale.LC_ALL, settings['localization'])
if 'timezone' not in settings:
settings['timezone'] = DefaultTimeZone
config = Configurator(settings=settings,
root_factory='sipkd.models.RootFactory',
session_factory=session_factory)
config.include('pyramid_beaker')
config.include('pyramid_chameleon')
authn_policy = AuthTktAuthenticationPolicy('sosecret',
callback=group_finder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.add_request_method(get_user, 'user', reify=True)
config.add_request_method(get_title, 'title', reify=True)
config.add_notfound_view(RemoveSlashNotFoundViewFactory())
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view('deform_static', 'deform:static')
config.add_static_view('files', settings['static_files'])
config.add_renderer('csv', '.tools.CSVRenderer')
routes = DBSession.query(Route.kode, Route.path, Route.nama).all()
for route in routes:
#if route.factory and route.factory != 'None':
# config.add_route(route.kode, route.path) #(route.factory).encode("utf8"))
#else:
config.add_route(route.kode, route.path)
if route.nama:
titles[route.kode] = route.nama
############################################################################
config.include('pyramid_rpc.jsonrpc') # JSON RPC
json_renderer = JSON()
json_renderer.add_adapter(datetime.datetime, lambda v, request: v.isoformat())
json_renderer.add_adapter(datetime.date, lambda v, request: v.isoformat())
config.add_renderer('myjson', json_renderer)
#config.add_jsonrpc_endpoint('ws_user', '/ws/user', default_renderer="myjson")
config.add_jsonrpc_endpoint('ws_sipkd', '/ws/sipkd', default_renderer="myjson")
############################################################################
config.scan()
app = config.make_wsgi_app()
from paste.translogger import TransLogger
app = TransLogger(app, setup_console_handler=False)
return app
示例9: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
if settings['bphtb_sqlalchemy.url']:
bphtb_engine = engine_from_config(settings, 'bphtb_sqlalchemy.')
BphtbDBSession.configure(bind=bphtb_engine)
BphtbBase.metadata.bind = bphtb_engine
if settings['pbb_sqlalchemy.url']:
pbb_engine = engine_from_config(settings, 'pbb_sqlalchemy.')
PbbDBSession.configure(bind=pbb_engine)
PbbBase.metadata.bind = pbb_engine
if settings['padl_sqlalchemy.url']:
padl_engine = engine_from_config(settings, 'padl_sqlalchemy.')
PadlDBSession.configure(bind=padl_engine)
PadlBase.metadata.bind = padl_engine
init_model()
json_renderer = JSON()
json_renderer.add_adapter(datetime.datetime, lambda v: v.isoformat())
session_factory = session_factory_from_settings(settings)
if 'localization' not in settings:
settings['localization'] = 'id_ID.UTF-8'
locale.setlocale(locale.LC_ALL, settings['localization'])
if 'timezone' not in settings:
settings['timezone'] = DefaultTimeZone
config = Configurator(settings=settings,
root_factory='jsonrpc.models.RootFactory',
session_factory=session_factory)
config.include('pyramid_beaker')
config.include('pyramid_chameleon')
config.include('pyramid_rpc.jsonrpc')
config.add_renderer('json', json_renderer)
authn_policy = AuthTktAuthenticationPolicy('sosecret',
callback=group_finder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.add_request_method(get_user, 'user', reify=True)
config.add_request_method(get_title, 'title', reify=True)
config.add_notfound_view(RemoveSlashNotFoundViewFactory())
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view('deform_static', 'deform:static')
for name, path, title in routes:
config.add_route(name, path)
config.add_jsonrpc_endpoint('pbb', '/pbb', default_renderer="json")
config.add_jsonrpc_endpoint('bphtb', '/bphtb')
config.add_jsonrpc_endpoint('padl', '/padl')
config.scan()
return config.make_wsgi_app()
示例10: main
# 需要导入模块: from pyramid.config import Configurator [as 别名]
# 或者: from pyramid.config.Configurator import add_jsonrpc_endpoint [as 别名]
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
init_model()
#if 'pbb.url' in settings and settings['pbb.url']:
pbb_engine = engine_from_config(settings, 'pbb.')
pbb_DBSession.configure(bind=pbb_engine)
pbb_Base.metadata.bind = pbb_engine
pbb_Base.pbb_schema = settings['pbb_schema'] or None
#pbb = {'kd_kanwil':settings['pbb_kd_kanwil'] or '01',
# 'kd_kantor':settings['pbb_kd_kantor'] or '01',}
session_factory = session_factory_from_settings(settings)
if 'localization' not in settings:
settings['localization'] = 'id_ID.UTF-8'
locale.setlocale(locale.LC_ALL, settings['localization'])
if 'timezone' not in settings:
settings['timezone'] = DefaultTimeZone
config = Configurator(settings=settings,
root_factory='opensipkdrpc.models.RootFactory',
session_factory=session_factory)
config.include('pyramid_beaker')
config.include('pyramid_chameleon')
authn_policy = AuthTktAuthenticationPolicy('sosecret',
callback=group_finder, hashalg='sha512')
authz_policy = ACLAuthorizationPolicy()
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.add_request_method(get_user, 'user', reify=True)
config.add_request_method(get_title, 'title', reify=True)
config.add_notfound_view(RemoveSlashNotFoundViewFactory())
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_static_view('deform_static', 'deform:static')
config.add_static_view('files', settings['static_files'])
############################################################################
config.include('pyramid_rpc.jsonrpc') # JSON RPC
json_renderer = JSON()
json_renderer.add_adapter(datetime.datetime, lambda v, request: v.isoformat())
json_renderer.add_adapter(datetime.date, lambda v, request: v.isoformat())
config.add_renderer('myjson', json_renderer)
config.add_jsonrpc_endpoint('ws_user', '/ws/user', default_renderer="myjson")
config.add_jsonrpc_endpoint('ws_pbb', '/ws/pbb', default_renderer="myjson")
############################################################################
routes = DBSession.query(Route.kode, Route.path, Route.nama).all()
for route in routes:
config.add_route(route.kode, route.path)
if route.nama:
titles[route.kode] = ' - '.join([main_title, route.nama])
config.scan()
app = config.make_wsgi_app()
from paste.translogger import TransLogger
app = TransLogger(app, setup_console_handler=False)
return app