没有项目描述
gakp-pylib的Python项目详细描述
`_初始化py`
``python
from.patients从pylib.falcon导入病人
jsontranslator()
]
异常。to_json())
api.set_error_serializer(u json_error_serializer)
patients.register(api)
```````
`patients.py`
``python
from pylib.schema import validators
from pylib.falcon import collection
from marshmallow import schema
from marshmallow.fields import int,str,date
=[]
计数器=0
def authenticate(req,resp,res,params):
通过
def authorize(req,resp,res,参数):
pass
class patientschema(schema):
id=int()
firstname=str(必选=true)
surname=str()
dob=date()
homephone=str(validate=validators.phone戡check)
patients=collection(
'/api/patients','pid',
patientschema(),before=[验证]
def具有相同的关键字谓词(关键字,查询):
def predicate(patient):
value=patient.get(key)
返回值和值。startswith(query)
return predicate
@patients.search(before=[authorize])
def search(query,query_type,**kwargs):
如果查询为none:
返回所有的病人
如果查询类型不是其他类型,则查询类型为“firstname”查询类型
返回列表(过滤器(
具有相同的关键字谓词(查询类型,查询),
所有患者))
@patients.create(before=[授权])
def create(patient,**kwargs):
所有患者。附加(患者)
返回len(所有患者)-1
@patients.read(before=[授权])
def get(pid):
if pid<;len(所有患者):
返回所有患者[pid]
@patients.update(before=[授权])
def update(pid,患者):
if pid<;len(所有患者):
所有患者[pid]=患者
返回患者
@patients.delete(before=[授权])
def delete(pid):
如果pid<;len(所有患者):
patient=所有患者[pid]
所有患者。pop(pid)
返回患者
```
``python
from.patients从pylib.falcon导入病人
jsontranslator()
]
异常。to_json())
api.set_error_serializer(u json_error_serializer)
patients.register(api)
```````
`patients.py`
``python
from pylib.schema import validators
from pylib.falcon import collection
from marshmallow import schema
from marshmallow.fields import int,str,date
=[]
计数器=0
def authenticate(req,resp,res,params):
通过
def authorize(req,resp,res,参数):
pass
class patientschema(schema):
id=int()
firstname=str(必选=true)
surname=str()
dob=date()
homephone=str(validate=validators.phone戡check)
patients=collection(
'/api/patients','pid',
patientschema(),before=[验证]
def具有相同的关键字谓词(关键字,查询):
def predicate(patient):
value=patient.get(key)
返回值和值。startswith(query)
return predicate
@patients.search(before=[authorize])
def search(query,query_type,**kwargs):
如果查询为none:
返回所有的病人
如果查询类型不是其他类型,则查询类型为“firstname”查询类型
返回列表(过滤器(
具有相同的关键字谓词(查询类型,查询),
所有患者))
@patients.create(before=[授权])
def create(patient,**kwargs):
所有患者。附加(患者)
返回len(所有患者)-1
@patients.read(before=[授权])
def get(pid):
if pid<;len(所有患者):
返回所有患者[pid]
@patients.update(before=[授权])
def update(pid,患者):
if pid<;len(所有患者):
所有患者[pid]=患者
返回患者
@patients.delete(before=[授权])
def delete(pid):
如果pid<;len(所有患者):
patient=所有患者[pid]
所有患者。pop(pid)
返回患者
```