I would put the addCustomer method on something other than the customer
object, like the thing you're adding the customer to. Or bettery yet,
you'd probably be just appending the customer. I think for your
specific example, you should handle customer creation stuff (login +
password) in __init__.
class Customer(object):
def __init__(self, login, secret):
self.password = secret
self.login = login
# from Michael's example
def _set_password(self, pw):
self._password = sha1(pw)
def _get_password(self):
return self._password
# other helper functions.
def activate(self):
self.status = 'a'
def inactivate(self):
self.status = 'i'
def annoyOnThePhone(self):
dialAsteriskAndAnnoy(self.phone_number)
def sendMonthlyBill(self):
# stuff
pass
customer = Customer('thelogin', 'thesecret')
store.customers.append(customer)
customer.activate()
--Randall
Jessica Meyer wrote:
> Thank you for your replies.
>
> With helper code I mean:
>
> I want the architecture of my program so:
>
> - There's a database
> - Only SQLAlchemy talks to the database
> - There is a function for every task that SQLAlchemy does
>
> So, I want to do something like this in the end: addCustomer
> (login='mylogin', password='secret', ...) and the function
> "addCustomer" checks input, creates a hash of the password and so on..
> And that helper function then uses the SQLAlchemy API. I mean, I think
> you're all doing this too, since nobody wants to call the SQLalchemy
> API every time again and again.
>
> Thanks
> Jess
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---