Skip to content

Instantly share code, notes, and snippets.

@k4ml
Created January 29, 2014 23:26
Show Gist options
  • Select an option

  • Save k4ml/8699461 to your computer and use it in GitHub Desktop.

Select an option

Save k4ml/8699461 to your computer and use it in GitHub Desktop.
POPO - Plain Old Python Object
class Messaging(object):
def __init__(self, user, sender, receiver, message):
self.user = user
self.sender = sender
self.receiver = receiver
self.message = message
def send(self):
required_points = self.get_required_points()
if required_points > self.user.points:
raise Exception('Not enough points')
return self.backend.send(self.sender, self.receiver, self.message)
@gcaraciolo
Copy link

hi @k4ml, I'm new to django/python and I'm looking for articles, books, etc, about the strategy of using pure python objects to place complex business logic. My biggest difficult now is about django project structures. Where this kind of classes should be placed?

do you have any sources related to this?

@khodemehran
Copy link

hi @k4ml, I'm new to django/python and I'm looking for articles, books, etc, about the strategy of using pure python objects to place complex business logic. My biggest difficult now is about django project structures. Where this kind of classes should be placed?

do you have any sources related to this?

hi gcaraciolo
Service objects are plain old Python objects (POPOs) that encapsulate a
service or interactions with a system. They are usually kept in a separate
file named services.py or utils.py.

@gabrielsimas
Copy link

I'm in 2024 and enjoying this thread. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment