Exemplo n.º 1
0
def api_callback(self,callback,args = None,post_data = None):
 #currently, we allow api to be called crossdomain
 web.header('Access-Control-Allow-Origin','*')
 web.header('Content-Type','application/json; charset=utf-8')

 answer = { 'error' : None }
 try:
  time_begin = time()

  answer['is_server_present'] = State.is_server_present()
  if self.need_server and not answer['is_server_present']:
   raise NoServerError('This operation requires vestibule server present')

  context,request = parse_post_data(post_data, self.readers, args)
  request['answer'] = answer

  context.apply(callback, args = (self,), kwds = request)
  if hasattr(context,'exc_info'):
   answer['error'] = format_exception(*context.exc_info)

 except Exception as e:
  answer['error'] = format_exception(*exc_info())
 finally:
  answer['time_elapsed'] = time() - time_begin
 return answer
Exemplo n.º 2
0
Arquivo: version.py Projeto: stdk/u2py
 def POST(self,reader = None,answer={},**kw):
  if reader != None:
   try:
    answer['sn'] = reader.sn()
   except ReaderError:
    answer['sn'] = None

   answer['version'] = reader.version()   
  else:
   answer['version'] = __version__
   answer['stoplist'] = State.get_stoplist_version()