{"id":24828205,"url":"https://github.com/chatopera/compose4py","last_synced_at":"2025-03-26T01:20:57.083Z","repository":{"id":62564197,"uuid":"248902311","full_name":"chatopera/compose4py","owner":"chatopera","description":"Onion Model in Python.","archived":false,"fork":false,"pushed_at":"2020-03-28T15:48:59.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T07:07:13.774Z","etag":null,"topics":["onion-model","python3"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chatopera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-21T03:51:20.000Z","updated_at":"2020-03-28T15:49:01.000Z","dependencies_parsed_at":"2022-11-03T16:45:46.893Z","dependency_job_id":null,"html_url":"https://github.com/chatopera/compose4py","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fcompose4py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fcompose4py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fcompose4py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chatopera%2Fcompose4py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chatopera","download_url":"https://codeload.github.com/chatopera/compose4py/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245568923,"owners_count":20636864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["onion-model","python3"],"created_at":"2025-01-30T22:51:47.349Z","updated_at":"2025-03-26T01:20:57.064Z","avatar_url":"https://github.com/chatopera.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compose4py\n\nOnion Model in Python.\nPyton 洋葱模型\n\n```\npip install compose4py\n```\n\n## Installation\n\n## Usage\n\nImport `compose4py`:\n\n```\nfrom compose4py import Compose\n```\n\nAll the usual function composition you know and love:\n\n```\n    def mw_1(ctx, loader_context):\n        print(\"mw_1: %s\" % ctx)\n        print(\"mw_1 loader_context: %s\" % loader_context)\n        ctx += \":mw1\"\n        # call the next middleware and waiting the new ctx\n        ctx = yield ctx\n        # use the latest ctx and process more logic\n        ctx += \":post_mw1\"\n        return ctx\n\n    def mw_2(ctx):\n        print(\"mw_2: %s\" % ctx)\n        ctx += \":mw2\"\n        ctx = yield ctx\n        ctx += \":post_mw2\"\n        return ctx\n\n    def mw_3(ctx):\n        print(\"mw_3: %s\" % ctx)\n        ctx += \":mw3\"\n        return ctx\n\n    compose = Compose(mw_1, mw_2, mw_3, loader_context = {\"foo\": \"bar\"})\n    result = compose(\"foo\")\n    print(\"final: %s\" % result)\n    # final: foo:mw1:mw2:mw3:post_mw2:post_mw1\n```\n\n## Give credits to\n\n[scrapy](https://github.com/scrapy/scrapy)\n\n## 开源许可协议\n\nCopyright (2018-2020) \u003ca href=\"https://www.chatopera.com/\" target=\"_blank\"\u003e北京华夏春松科技有限公司\u003c/a\u003e\n\n[Apache License Version 2.0](https://github.com/chatopera/cosin/blob/master/LICENSE)\n\n[![chatoper banner][co-banner-image]][co-url]\n\n[co-banner-image]: https://user-images.githubusercontent.com/3538629/42383104-da925942-8168-11e8-8195-868d5fcec170.png\n[co-url]: https://www.chatopera.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatopera%2Fcompose4py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchatopera%2Fcompose4py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchatopera%2Fcompose4py/lists"}