コード例 #1
0
ファイル: query.py プロジェクト: azer/dasornis
  def __call__(self,*args,**kwargs):
    """
    Handles calling event of the classes.Executes given query using database driver.
    Returns instances of Entity classes which will be mapped to sub query classes.
    """
    self.args = args or kwargs or None
    if not self.code:
      raise Exception, "'code' property has to be an sql query"

    if self.args:
      code = self.code%self.args
    else:
      code = self.code

    logging.info('db.query: Running new query; %s'%(code.replace('\n',' ')))
    """
    Executing given query
    """
    from __init__ import connection
    connection.cursor.execute(code)

    try:
      data = connection.cursor.fetchall()
    except:
      data = tuple()
      logging.error( ExceptionInfo().format_stack() )

    """
    Mapping fetched data into python objects
    """
    self.data = QueryResult(data)
    self.data.query = self
    self.data = ( None if len(self.data)==0 else self.data[0] ) if self.is_singular else self.data

    return self.data
コード例 #2
0
ファイル: pages.py プロジェクト: azer/dasornis
 def get(self,excstack):
   ErrorPage.get(self)
   logging.error("INTERNAL ERROR")
   logging.error('  %s'%excstack.type)
   logging.error('  %s'%excstack.value)
   logging.error('  %s'%excstack.format_stack())
   self.template.args.append( ('excstack',excstack) )
   if not self.template.args[3][1]:
     self.template.args[3] = ('description',excstack.value)
コード例 #3
0
ファイル: exception_info.py プロジェクト: azer/dasornis
 def log(self):
   logging.error('EXCEPTION INFO: type: %s, file:%s, function:%s, line: %i, message: %s'%(
     str(self.type),self.stack[-1][0],self.stack[-1][2],self.stack[-1][1],self.value.message
     )
   )