Skip to content

Commit

Permalink
Hotpatch to fix bug in 0.9.0
Browse files Browse the repository at this point in the history
Using facade instead of BaseFacade
  • Loading branch information
dkarchmer committed Aug 20, 2023
1 parent 519b2f5 commit e1a9990
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v0.9.1 (2023-08-20)

* Fix bug using old Facade instead of BaseFacade

### v0.9.0 (2023-08-20)

* Add isort and Black as formatter
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Here is a sample script:

```python
from drf_client.helper.base_main import BaseMain
from drf_client.helper.facade import Facade
from drf_client.helper.base_facade import BaseFacade

class MyScript(BaseMain):

Expand All @@ -152,7 +152,7 @@ class MyScript(BaseMain):
# Main function to OVERWITE and do real work
resp = self.api.foo.bar.get()
# You can also access the API from the global Facade
resp = Facade.api.foo.bar.get()
resp = BaseFacade.api.foo.bar.get()


if __name__ == '__main__':
Expand Down
19 changes: 16 additions & 3 deletions drf_client/helpers/base_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
import sys
from urllib.parse import urlparse

from .facade import Facade
from .base_facade import BaseFacade

LOG = logging.getLogger(__name__)


class BaseMain:
"""Boiler plate code for basic scripts.
The class assumes that most scripts include the basic following flow:
- Parse arguments
- Setup LOG configuration
- Login
- Do something after logging in
"""

parser = None
args = None
api = None
Expand Down Expand Up @@ -55,8 +65,10 @@ def __init__(self):

self.args = self.parser.parse_args()
self.config_logging()
self.domain = ""

def _critical_exit(self, msg):
"""Exit with an error."""
LOG.error(msg)
sys.exit(1)

Expand All @@ -70,8 +82,8 @@ def main(self):
"""
self.domain = self.get_domain()
# Create a static pointer to the API for global access
Facade.initialize_api(options=self.get_options(), args=self.args)
self.api = Facade.api
BaseFacade.initialize_api(options=self.get_options(), args=self.args)
self.api = BaseFacade.api
self.before_login()
ok = self.login()
if ok:
Expand All @@ -81,6 +93,7 @@ def main(self):
# ================================================

def get_options(self):
"""Add domain to Api options."""
options = self.options
options["DOMAIN"] = self.domain
return options
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="django-rest-framework-client",
version="0.9.0",
version="0.9.1",
description="Python client for a DjangoRestFramework based web site",
long_description=README,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit e1a9990

Please sign in to comment.