Ejemplo n.º 1
0
  def __init__(self,date,dbfn,loglevel):
    super(PayPyDB,self).__init__()
    #connect to database
    logging.basicConfig()
    try:
      self.__storage__=storageFromURL('paypydb.conf')
    except:
      self.__storage__=FileStorage.FileStorage(dbfn)
    self.__db__=DB(self.__storage__)
    self.__connection__=self.__db__.open()
    self.__dbroot__=self.__connection__.root()

    if not date in self.alldays():                         # if today date is exists then fill the 'data' attr
      #self.__fill_yesterday__()
      self.__dbroot__[date]=self.data                     # create database and 'newday' with zero data
      self.commit()                                        # commit changes
Ejemplo n.º 2
0
 def __init__(self,dbfn='Users.db',new=False,loglevel=''):
   #connect to database
   try:
     self.__storage__=storageFromURL('usersdb.conf')
   except:
     self.__storage__=FileStorage.FileStorage(dbfn)
   self.__db__=DB(self.__storage__)
   self.__connection__=self.__db__.open()
   self.__dbroot__=self.__connection__.root()
   try:
     self.__dbroot__['all']
     if new:
       raise KeyError
   except KeyError:
     self.__dbroot__['all']={'passwd':'111','size':(500,1000),'schem':{'blocks':['date','inbal','incom','outgo','outbal','val_corr','val_mmvb','val_kassa','val_open'],'readonly':[]}}
     self.__dbroot__['rur']={'passwd':'222','size':(500,700),'schem':{'blocks':['date','inbal','incom','outgo','outgo2','outbal','outgofix'],'readonly':[['rur','outgofix'],['rur','incomtotal']]}}
     self.__dbroot__['val']={'passwd':'333','size':(500,800),'schem':{'blocks':['date','val_corr','val_mmvb','val_kassa','val_open'],'readonly':[]}}
     self.commit()