Changeset 53:ec3de0325406 in stamper for stamper/stamper.py


Ignore:
Timestamp:
Nov 8, 2014, 5:29:03 PM (6 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Authenticate the user before actually push the stamps to the server.
Also, cleaned up a bit the http client, no need to pass and store
there the user and password auth credentials.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stamper/stamper.py

    r52 r53  
    2020SECS_DAY = HOURS_DAY * 60 * 60
    2121REMOTE_BASE_URL = 'https://localhost'
    22 REMOTE_PUSH_URL = '/stamper/listen/'  # IMPORTANT: keep the trailing /
     22# IMPORTANT: keep the trailing / on these _URL variables
     23REMOTE_LOGIN_URL = '/stamper/login/'
     24REMOTE_PUSH_URL = '/stamper/listen/'
    2325REMOTE_USER = None
    2426REMOTE_PASSWORD = None
     
    453455                stamps.append(stamp)
    454456        stamps = json.dumps(stamps, indent=4)
    455         http_client = HTTPClient(REMOTE_BASE_URL, REMOTE_USER, REMOTE_PASSWORD)
     457        http_client = HTTPClient(REMOTE_BASE_URL)
     458        http_client.post(REMOTE_LOGIN_URL, {'username': REMOTE_USER,
     459                                            'password': REMOTE_PASSWORD})
    456460        http_client.post(REMOTE_PUSH_URL, {'stamps': stamps})
Note: See TracChangeset for help on using the changeset viewer.