Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and abstract out entity classes #57

Open
Olen opened this issue Jan 27, 2023 · 2 comments
Open

Refactor and abstract out entity classes #57

Olen opened this issue Jan 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Olen
Copy link
Owner

Olen commented Jan 27, 2023

Just an idea for now, please give some feedback.

I have been thinking about some refactoring where we create new classes for e.g. SpondEvent, SpondPerson, SpondGroup. SpondMessage etc.

It would allow us to keep a stable API even if Spond should change stuff, and do more things in a more consistent way.

Something along the lines of

event = SpondEvent()
event.begin = "2023-01-30 13:00:00"
event.end = "2023-01-30 17:00:00"
event.name = "Race"
event.location = SpondLocation(address="Foo Street 123")
event.save()

After saving the event, the object is populated with an event.id.

You can change it later:

event = SpondEvent(event_id)
event.begin = "2023-01-27 14:00:00"
event.save()

There should also be some validations done (start < end etc) before saving.

And similar for persons, messages etc.

person = SpondPerson(person_id)
print(person.first_name)

It also allows for creating shortcuts for things like

class SpondPerson():
    ...
    @property
    def name(self):
        return f"{self.first_name} {self.last_name}"
@elliot-100
Copy link
Collaborator

I've actually written a partial implementation of this, as a separate, compatible package for now.

It only covers what I need for my read-only use cases, and I am sure it is naïve in some places. It was largely a learning exercise for me.

It sounds like I should make it public in case it is useful. I will do that in the next few days.

@elliot-100
Copy link
Collaborator

Initial, very partial release: https://github.com/elliot-100/Spond-classes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants