CherrypyElixir-0.5.1
توضیحات
Elixir plugin for cherrypy
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | CherrypyElixir-0.5.1 |
| نام | CherrypyElixir |
| نسخه کتابخانه | 0.5.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Vahid Mardani |
| ایمیل نویسنده | vahid.mardani@gmail.com |
| آدرس صفحه اصلی | http://packages.python.org/cherrypyelixir |
| آدرس اینترنتی | https://pypi.org/project/CherrypyElixir/ |
| مجوز | UNKNOWN |
.. pymlconf documentation master file, created by
sphinx-quickstart on Sat Apr 14 05:05:05 2012.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Cherrypy's Elixir Plugin
====================================
``CherrypyElixir`` is a cherrypy plugin that provides elixir functionalities on top of sqlalchemy , within cherrypy as a process bus plugin.
Example::
import cherrypy
import CherrypyElixir
from elixir import Entity, String, Field, OneToMany, Unicode, ManyToOne
CherrypyElixir.setup()
# define models
class Person(Entity):
name = Field(String(128))
addresses = OneToMany('Address')
class Address(Entity):
email = Field(Unicode(128))
owner = ManyToOne('Person')
class Root(object):
@cherrypy.expose
@cherrypy.tools.elixir()
def index(self):
yield '<ul>'
for p in Person.query:
yield '<li>'
yield p.name
yield ' '
yield ','.join([a.email for a in p.addresses])
yield '</li>'
yield '</ul>'
@cherrypy.expose
@cherrypy.tools.elixir()
def add(self,name=None,address=None):
p = Person(name = name)
for addr in address.split(','):
p.addresses.append(Address(email=addr))
_cp_config={
'global':{
'server.socket_host' : '0.0.0.0',
'server.socket_port' : 1919,
'engine.elixir.on' : True,
'engine.elixir.echo' : True,
'engine.elixir.db_uri' : 'sqlite://test.db'
},
}
if __name__ == '__main__':
cherrypy.quickstart(Root(), '', config=_cp_config)
To access sqlalchemy's ``scoped_session`` directly , you can use ``cherrypy.request.db``
نحوه نصب
نصب پکیج whl CherrypyElixir-0.5.1:
pip install CherrypyElixir-0.5.1.whl
نصب پکیج tar.gz CherrypyElixir-0.5.1:
pip install CherrypyElixir-0.5.1.tar.gz