Created
February 22, 2016 08:19
-
-
Save prodeveloper/4cb1f18cb1487c5c36b3 to your computer and use it in GitHub Desktop.
Organizing python code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
# Code in your services folder | |
class StoreInDb(): | |
def run(data): | |
StoreInDb.storeLogic(data) | |
data['db_status'] = "User stored in database" | |
def storeLogic(data): | |
pass | |
class RegisterNewsletter(): | |
def run(data): | |
RegisterNewsletter.registerLogic(data) | |
data['newsletter_status'] = "User registered newsletter" | |
def registerLogic(data): | |
pass | |
class SendConfirmation(): | |
def run(data): | |
SendConfirmation.emailingLogic(data) | |
data['confirmation_status'] = "User Sent confirmation letter" | |
def emailingLogic(data): | |
pass | |
# Code in your controller | |
data = {'firstName': 'John', 'sirName': 'Doe', 'email': 'john@doe.com'} | |
StoreInDb.run(data) | |
RegisterNewsletter.run(data) | |
print(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment