예제 #1
0
 def match(self, table, whereClause=None, orderBy=None, **simple):      
     assert not (whereClause and simple), \
            "where/simple queries are mutually exclusive"
     if simple:
         whereClause = reduce(operator.and_,
                              [where(k)==simple[k] for k in simple])
     return self._match(table, whereClause, orderBy)
예제 #2
0
    def check_querybuilder_matches(self):
        self.check_store_insertExtra()
        match = self.s.match("test_person", where("ID") == 5)
        assert match[0]['name'] == 'jack'

        match = self.s.match("test_person", ((where("name") == "fred")
                                             | (where("name") == "bob")),
                             "name")
        self.assertEquals([u['name'] for u in match], ['bob', 'fred'])

        match = self.s.match("test_person", ((where("ID") > 1)
                                             & (where("ID") <= 4))
                             | (where("name").endswith('ck')), 'name desc')
        self.assertEquals([u['name'] for u in match],
                          ['wanda', 'rick', 'jack', 'bob'])
예제 #3
0
    def check_querybuilder_matches(self):
        self.check_store_insertExtra()
        match = self.s.match("test_person", where("ID")==5 )
        assert match[0]['name'] == 'jack'

        match = self.s.match("test_person", ( ( where("name")=="fred" )
                                         |  ( where("name")=="bob" ) ), "name")
        self.assertEquals([u['name'] for u in match],
                          ['bob','fred'])
            
        
        
        match = self.s.match("test_person", ((where("ID") > 1)
                                             &(where("ID") <= 4))
                                           |(where("name").endswith('ck')),
                                         'name desc')
        self.assertEquals( [u['name'] for u in match],
                           ['wanda', 'rick', 'jack', 'bob'] )
예제 #4
0
 def fetch(self, table, ID):
     res = self.match(table, where("ID") == ID)
     if len(res)!=1:
         raise LookupError, "match(%r, ID=%r) returned %i rows." \
               % (table, ID, len(res))
     return res[0]
예제 #5
0
 def test_simple(self):
     clause = where('a') < 5
     assert str(clause) == "(a < '5')", clause
예제 #6
0
 def test_like(self):
     clause = where("name").startswith("a")
     self.assertEquals(str(clause), "(name LIKE 'a%')")
예제 #7
0
 def test_complex(self): 
     a = where("a") == 1
     b = where("b") == 2
     #import pdb; pdb.set_trace()
     clause = a | b
     self.assertEquals(str(clause), "((a = '1') OR (b = '2'))")
예제 #8
0
 def check_oldmatch(self):
     self.check_store_insertExtra()
     match = self.s.match("test_person", where("ID") == 2)
     assert match[0]["name"] == "wanda", "new style broke"
     match = self.s.match("test_person", ID=2)
     assert match[0]["name"] == "wanda", "old style broke"
예제 #9
0
 def check_match(self):
     assert self.wholedb() == []
     self.populate()
     results = self.s.match("test_person", where("ID") == 1)
     assert results == [{"ID": 1, "name": "fred"}], str(results)
예제 #10
0
        sendmail(header + msg + stmt)




if __name__=="__main__":

    CLERK = duckbill.config.makeClerk()

    today = Date("today")
    lastDue = today - daysInLastMonth() + 15
    nextDue = today + 15

    dueAccounts = []

    for acc in CLERK.match(duckbill.Account, where("status") != "closed"):
        #@TODO: can I do multiple where clauses?
        if acc.status=="comped": continue
        
        ## @TODO: call postCharges() but figure out how to trap errors [??]

        for sub in acc.subscriptions:
            try:
                sub.catchup()
                CLERK.store(acc) # not sub, because of bug...
            except Exception, e:
                print "ERROR [%s>%s]:" % (acc.account, sub.username), str(e)


        if acc.isDue():
            dueAccounts.append(acc)
예제 #11
0
 def check_match(self):
     assert self.wholedb() == []
     self.populate()
     results = self.s.match("test_person", where("ID") == 1)
     assert results == [{"ID":1, "name":"fred"}], str(results)
예제 #12
0
 def check_oldmatch(self):
     self.check_store_insertExtra()
     match = self.s.match("test_person", where("ID")==2)
     assert match[0]["name"] == "wanda", "new style broke"
     match = self.s.match("test_person", ID=2)
     assert match[0]["name"] == "wanda", "old style broke"
예제 #13
0
 def fetch(self, table, ID):
     res = self.match(table, where("ID") == ID)
     if len(res) != 1:
         raise LookupError, "match(%r, ID=%r) returned %i rows." \
               % (table, ID, len(res))
     return res[0]
예제 #14
0
 def test_complex(self):
     a = where("a") == 1
     b = where("b") == 2
     #import pdb; pdb.set_trace()
     clause = a | b
     self.assertEquals(str(clause), "((a = '1') OR (b = '2'))")
예제 #15
0
 def test_simple(self):
     clause = where('a') < 5
     assert str(clause) == "(a < '5')", clause
예제 #16
0
 def test_like(self):
     clause = where("name").startswith("a")
     self.assertEquals(str(clause), "(name LIKE 'a%')")