Name | py-service-object JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | A Python implementation of the Service Object pattern, inspired by Ruby's SimpleCommand gem |
upload_time | 2024-11-23 12:52:46 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2024 Vitor Pereira Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
business-logic
design-pattern
service-object
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# py-service-object
A Python implementation of the Service Object pattern, inspired by Ruby's SimpleCommand gem.
## Installation
```bash
pip install py-service-object
```
## Usage
```python
from py_service_object import ServiceObject
class CreateUser(ServiceObject):
def __init__(self, user_params):
self.user_params = user_params
super().__init__()
def call(self):
try:
user = User.create(self.user_params)
return user
except Exception as e:
self.errors.append({"message": str(e)})
return None
```
## Using the ServiceObject
```python
service = CreateUser(user_params)
if service.success:
user = service.result
else:
errors = service.errors
```
## Features
- Encapsulates business logic in dedicated classes
- Built-in error handling
- Result caching
- Clean and consistent interface
- Type hints support
Raw data
{
"_id": null,
"home_page": null,
"name": "py-service-object",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "business-logic, design-pattern, service-object",
"author": null,
"author_email": "Vitor Pereira <pvitorpereira@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/cb/5c/04bca7101f2331e99a53aaf1e401a6009f5fd9818bdbd89ce8363b18617d/py_service_object-0.1.1.tar.gz",
"platform": null,
"description": "# py-service-object\n\nA Python implementation of the Service Object pattern, inspired by Ruby's SimpleCommand gem.\n\n## Installation\n\n```bash\npip install py-service-object\n```\n\n## Usage\n\n```python\nfrom py_service_object import ServiceObject\n\nclass CreateUser(ServiceObject):\n def __init__(self, user_params):\n self.user_params = user_params\n super().__init__()\n\n def call(self):\n try:\n user = User.create(self.user_params)\n return user\n except Exception as e:\n self.errors.append({\"message\": str(e)})\n return None\n```\n\n## Using the ServiceObject\n\n```python\nservice = CreateUser(user_params)\n\nif service.success:\n user = service.result\nelse:\n errors = service.errors\n```\n\n## Features\n\n- Encapsulates business logic in dedicated classes\n- Built-in error handling\n- Result caching\n- Clean and consistent interface\n- Type hints support\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Vitor Pereira Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A Python implementation of the Service Object pattern, inspired by Ruby's SimpleCommand gem",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/vitrpereira/py-service-object"
},
"split_keywords": [
"business-logic",
" design-pattern",
" service-object"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "844d881e20e70a9f4081d0068eaaad69ba1d95236148b3f99ab4fbd70318b653",
"md5": "c99768059c811215c85aea63be698528",
"sha256": "a87d5f6772124cf78e86e628ac25f028838587b1c33a08a823f672865062e12b"
},
"downloads": -1,
"filename": "py_service_object-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c99768059c811215c85aea63be698528",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4674,
"upload_time": "2024-11-23T12:52:45",
"upload_time_iso_8601": "2024-11-23T12:52:45.206148Z",
"url": "https://files.pythonhosted.org/packages/84/4d/881e20e70a9f4081d0068eaaad69ba1d95236148b3f99ab4fbd70318b653/py_service_object-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cb5c04bca7101f2331e99a53aaf1e401a6009f5fd9818bdbd89ce8363b18617d",
"md5": "e0a4c79a53d7cd8bea603b10c4256b98",
"sha256": "70cb3e370c080e55da2ee82e223acc8f653b58cd14272423d8e5f0fe17af12bd"
},
"downloads": -1,
"filename": "py_service_object-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "e0a4c79a53d7cd8bea603b10c4256b98",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4070,
"upload_time": "2024-11-23T12:52:46",
"upload_time_iso_8601": "2024-11-23T12:52:46.906475Z",
"url": "https://files.pythonhosted.org/packages/cb/5c/04bca7101f2331e99a53aaf1e401a6009f5fd9818bdbd89ce8363b18617d/py_service_object-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-23 12:52:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vitrpereira",
"github_project": "py-service-object",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-service-object"
}