def setApiKey(self, key):
		self.key = key

		if key is not None:
			try:
				ATM_ = ATM()
				apikey = ATM_.findByKey(key)
				
				if apikey is None:
					raise Unauthorised("An invalid API token was supplied.")

				self.apikey = apikey
				self.user = self.apikey.getUser()

			except mdb.DatabaseError, e:
				raise ServerError("Unable to search the user database (%s)" % e.args[1])

			except:
Esempio n. 2
0
    def setApiKey(self, key):
        self.key = key

        if key is not None:
            try:
                ATM_ = ATM()
                apikey = ATM_.findByKey(key)

                if apikey is None:
                    raise Unauthorised("An invalid API token was supplied.")

                self.apikey = apikey
                self.user = self.apikey.getUser()

            except mdb.DatabaseError, e:
                raise ServerError("Unable to search the user database (%s)" %
                                  e.args[1])

            except: