def post(self): v = {} v.update(draft_info(self)) di = dropox_info.get_by_key_name('DROPBOX_SECRETS') di.app_key = self.request.get('app_key') di.app_secret = self.request.get('app_secret') di.save() try: DB = dropbox_api() except: v['error'] = True render.page(self, html_template, values=v) if not v.get('error', False): meta = DB.request_meta('/pics') if 'error' in meta: # -> attempt oauth # redirect to handshake self.redirect('/sync/login') else: # -> user is authorized v.update({'app_key': di.app_key, 'app_secret': di.app_secret}) sync_datastore() now = datetime.now().replace(tzinfo=pytz.utc) message = 'synced @ %s' % (now.astimezone(pytz.timezone('America/New_York')).strftime('%I:%M:%S%p %Z')) v['sync'] = message render.page(self, html_template, values=v)
def get(self): v = {} v.update(draft_info(self)) db_info = dropox_info.get_by_key_name('DROPBOX_SECRETS') if db_info == None: # -> new user di = dropox_info( key_name='DROPBOX_SECRETS', ) # initialize di.put() # initialize else: # -> returning user v.update({'app_key': db_info.app_key, 'app_secret': db_info.app_secret}) render.page(self, html_template, values=v)