跳转到主要内容

Lean架构强制的对象

项目描述

Travis

https://img.shields.io/travis/rshk/contracts.svg

CircleCI

https://img.shields.io/circleci/project/rshk/contracts.svg

Python定义“合约”模型的基础库。

摘要

这是一个类似于你在大多数ORM/表定义系统中看到的“模型”实现,但主要目标是尽可能保持简单。

不涉及元类或描述符;也不会有破坏标准Python对象功能的黑客代码。

想法是有一个“分层”的库,提供定义你自己的模式所需的裸骨,以及一些针对常见情况的辅助工具。

用例

  • API客户端

  • ORM

  • 表单

示例模型定义

from contracts.core import Contract, BaseField

# Use BaseField to define your field types, eg. StringField and
# IntegerField.

class MyModel(BaseObject):
    first_name = StringField()
    last_name = StringField()
    age = IntegerField()

然后,创建一些库来以某种方式使用模式 😊。

项目详情


支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面