From: Bernard Blackham Date: Fri, 25 Jun 2004 10:47:43 +0000 (+0000) Subject: Changes X-Git-Tag: IMPORT-FROM-UCCCVS~160 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=6e99ab47bc4c632a1f43ad5e22e0fd27ce27677d;p=uccvend-vendserver.git Changes --- diff --git a/BankAccount.py b/BankAccount.py index ae33dd9..6565b65 100644 --- a/BankAccount.py +++ b/BankAccount.py @@ -19,7 +19,7 @@ class BankAccount: def sanity_check_user(self, user): wanted_fields = ['balance'] for f in user: - if wanted_fields.has_key(f): + if f in wanted_fields: if f == 'balance': if not isinstance(user['balance'], tuple): return False @@ -54,11 +54,13 @@ class BankAccount: def get_balance(self, username): if self.bank.has_key(username): - return self.bank['username']['balance'] + return self.bank[username]['balance'] return (0,0) def add_amount(self, username, amount): - ensure_user_exists(username) - self.bank['username']['balance'][0] += amount[0] - self.bank['username']['balance'][1] += amount[1] + self.ensure_user_exists(username) + (cur_cents, cur_bytes) = self.bank[username]['balance'] + (add_cents, add_bytes) = amount + self.bank[username]['balance'] = (cur_cents+add_cents, + cur_bytes+add_bytes) self.save() diff --git a/DispenseServer.py b/DispenseServer.py index 7b06713..467f1ff 100755 --- a/DispenseServer.py +++ b/DispenseServer.py @@ -6,11 +6,15 @@ from BankAccount import BankAccount namespace = 'Dispense' bind_port = 9900 +server = None + +def hello(): + return "hello", server.address_string() + if __name__ == '__main__': server = SOAPServer(('0.0.0.0', 9900)) bank = BankAccount() - for f in []: + for f in [hello]: server.registerFunction(f, namespace) print "Serving forever ..." server.serve_forever() -