kpages is api-centric web application framework for the Tornado and Mongodb
Project description
kpages
======
kpages is mini helper for tornado,Contains the address routing management,tornado and app config management, mongodb, redis connection management and other functions; these things can help you quickly build a web application.
基于Tornado的开发包,提供地址路由、配置、测试、性能分析、数据库及内存连接上下文管理等,如果你想用Tornado提供一些高性能的服务接口,这会给你很大的帮助的。
router
------
restful/index.py(add @url to class , kpages will route url to this handler)
---------------------------------------------------------------------------
from kpages import url
@url(r'/',0)
@url(r'/home',2)
class HomeHandler(RequestHandler):
def get(self):
self.write('hello word')
setting.py(config for tornado and you app, use __conf__.xxxx to get you config value )
--------------------------------------------------------------------------------------
ACTION_DIR = 'restful'
DEBUG = True
PORT= 8989
app.py
------
from kpages import run
if __name__ == '__main__':
run()
How to use mongo and redis context?
-----------------------------------
from kpages import get_context, LogicContext,mongo_conv
with LogicContext():
db = get_context().get_mongo()
cache = get_context().get_cache()
lst = list(db['table'].find().limit(10))
lst = mongo_conv(lst)
How to use context in hander?
-----------------------------
from kpages import ContextHandler
@url(r'/context/demo')
class DemoHandler(ContextHandler):
def get(self):
db = get_context().get_mongo('dbname')
test commend
------------
python app.py --test test_city.DemoCase.testprint :test testprint method
python app.py --test test_city.DemoCase :test methods in DemoCase class
python app.py --test test_city :test methods in test_city.py
python app.py --test all :test methods in app's __conf__.UTEST_DIR
pro commend
------------
python app.py --pro test_city.DemoCase.testprint :profile testprint method
python app.py --pro test_city.DemoCase :profile methods in DemoCase class
python app.py --pro test_city :profile methods in test_city.py
python app.py --pro all :profile methods in app's __conf__.UTEST_DIR
======
kpages is mini helper for tornado,Contains the address routing management,tornado and app config management, mongodb, redis connection management and other functions; these things can help you quickly build a web application.
基于Tornado的开发包,提供地址路由、配置、测试、性能分析、数据库及内存连接上下文管理等,如果你想用Tornado提供一些高性能的服务接口,这会给你很大的帮助的。
router
------
restful/index.py(add @url to class , kpages will route url to this handler)
---------------------------------------------------------------------------
from kpages import url
@url(r'/',0)
@url(r'/home',2)
class HomeHandler(RequestHandler):
def get(self):
self.write('hello word')
setting.py(config for tornado and you app, use __conf__.xxxx to get you config value )
--------------------------------------------------------------------------------------
ACTION_DIR = 'restful'
DEBUG = True
PORT= 8989
app.py
------
from kpages import run
if __name__ == '__main__':
run()
How to use mongo and redis context?
-----------------------------------
from kpages import get_context, LogicContext,mongo_conv
with LogicContext():
db = get_context().get_mongo()
cache = get_context().get_cache()
lst = list(db['table'].find().limit(10))
lst = mongo_conv(lst)
How to use context in hander?
-----------------------------
from kpages import ContextHandler
@url(r'/context/demo')
class DemoHandler(ContextHandler):
def get(self):
db = get_context().get_mongo('dbname')
test commend
------------
python app.py --test test_city.DemoCase.testprint :test testprint method
python app.py --test test_city.DemoCase :test methods in DemoCase class
python app.py --test test_city :test methods in test_city.py
python app.py --test all :test methods in app's __conf__.UTEST_DIR
pro commend
------------
python app.py --pro test_city.DemoCase.testprint :profile testprint method
python app.py --pro test_city.DemoCase :profile methods in DemoCase class
python app.py --pro test_city :profile methods in test_city.py
python app.py --pro all :profile methods in app's __conf__.UTEST_DIR
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kpages-0.5.2.dev.tar.gz
(9.2 kB
view hashes)