Make client id a static property
Sapan Bhatia [Tue, 9 Jul 2013 15:32:27 +0000 (11:32 -0400)]
fofum.py

index ab65226..3b30fc6 100755 (executable)
--- a/fofum.py
+++ b/fofum.py
@@ -39,13 +39,13 @@ class FofumException(Exception):
         
 
 class Fofum:
-    def run_action(self, action, hash='', message='',title='',client_id=''):
+    _client_id=''
+    def run_action(self, action, hash='', message='',title=''):
         event = json.dumps({'title':title})
-        params = {'action':action,'hash':hash,'payload':message,'u':self.user,'event':event}
+        params = {'action':action,'hash':hash,'payload':message,'u':self.user,'event':event,'client_id'=_client_id}
         return requests.get(FEEFIE_SERVER_URL, params=params)
 
     def make(self, title):
-        self.client_id = client_id
         ret_string = self.run_action('add',title=title)
         try:
             ret_dict = json.loads(ret_string.text)
@@ -60,7 +60,7 @@ class Fofum:
             raise FofumException('Error creating event. Malformed response: %s'%ret_string.text)
 
     def subscribe(self):
-        ret_string = self.run_action('subscribe', hash=self.hash, client_id=self.client_id)
+        ret_string = self.run_action('subscribe', hash=self.hash)
         try:
             ret_dict = json.loads(ret_string.text)
             if (ret_dict['status']!=0):
@@ -68,7 +68,7 @@ class Fofum:
             else:
                 try:
                     self.token = ret_dict['token']
-                    self.client_id = ret_dict['client_id']
+                    _client_id = ret_dict['client_id']
                 except KeyError:
                     raise FofumException('Error fetching token. Did not get token spec')
         except:
@@ -116,7 +116,7 @@ class Fofum:
                 
 
     def __init__(self,user='',hash=None,client_id=''):
-
+        _client_id = client_id
         # Check phantomjs dependency
         if (not os.access(PHANTOM_PATH,0)):
             raise FofumException('Phantomjs not installed.')