コード例 #1
0
ファイル: dbtests.py プロジェクト: xuamyj/amyjxj-infinite
    def my_txn():
        test_username = self.user.name
        self.write('<br>username is: ' + test_username)
        print('username is: ' + test_username)
        user = User.by_name(test_username)
        self.write('<br>user.id() is: ' + str(user.key().id()))
        print('user.id() is: ' + str(user.key().id()))

        # FOR DELETING
        delete_for_user(self, test_username)

        omlet1 = Omlet.make_omlet(test_username, 'amy1')
        print('omletparent', omlet1.parent().key().id());
        print('user', user.key().id())
        print('omlet:' + omlet1.name)
        key1 = omlet1.put()
        print('omlet1 newkey:', key1.id())
        omlet2 = Omlet.get_by_id(key1.id(),
            parent = user,
            read_policy = db.STRONG_CONSISTENCY)
        print('omlet2: ' + omlet2.name)
        self.write('<br><br>put in omlet called "amy1" ')
        self.write('<br>list of omlets for this user is ' + string_list_omlet(Omlet.list_username(test_username)))
        self.write('<br>look, the omlet exists: ' + string_omlet(Omlet.by_name('amy1')))

        self.write('<br><br>this should be empty: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))
        make_bite_noduplicate('amy1', 'Bite AAAAA')
        make_bite_noduplicate('amy1', 'This is bite B of omlet1')
        self.write('<br>this should have two bites: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))

        make_bite_noduplicate('amy1', 'Bite C')
        make_bite_noduplicate('amy1', 'Bite D, yay')
        make_bite_noduplicate('amy1', 'Nom, Bite E')
        self.write('<br><br> want up to bite C: ' + string_list_bite(Bite.list_omlet_until_number('amy1', 3)))
        self.write('<br> want bite D only: ' + string_bite(Bite.by_omlet_number('amy1', 4)))
コード例 #2
0
ファイル: dbtests.py プロジェクト: xuamyj/amyjxj-infinite
def my_txn():
    test_username = self.user.name
    self.write('<br>username is: ' + test_username)
    user = User.by_name(test_username)
    self.write('<br>user.id() is: ' + str(user.key().id()))

    # FOR DELETING
    delete_for_user(self, test_username)

    omlet1 = Omlet.make_omlet(test_username, 'amy1')
    if omlet1:
        omlet1.put()
    self.write('<br><br>put in omlet called "amy1" ')
    self.write('<br>list of omlets for this user is ' + string_list_omlet(Omlet.list_username(test_username)))
    self.write('<br>look, the omlet exists: ' + string_omlet(Omlet.by_name('amy1')))

    self.write('<br><br>this should be empty: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))
    make_bite_noduplicate('amy1', 'Bite AAAAA')
    make_bite_noduplicate('amy1', 'This is bite B of omlet1')
    self.write('<br>this should have two bites: ' + string_list_bite(Bite.list_omlet_until_number('amy1', None)))

    make_bite_noduplicate('amy1', 'Bite C')
    make_bite_noduplicate('amy1', 'Bite D, yay')
    make_bite_noduplicate('amy1', 'Nom, Bite E')
    self.write('<br><br> want up to bite C: ' + string_list_bite(Bite.list_omlet_until_number('amy1', 3)))
    self.write('<br> want bite D only: ' + string_bite(Bite.by_omlet_number('amy1', 4)))
コード例 #3
0
ファイル: bitedb.py プロジェクト: xuamyj/amyjxj-infinite
 def by_omlet_number(cls, omlet_name, number):
     omlet = Omlet.by_name(omlet_name)
     if not omlet:
         print('Tried to find Bite - Omlet does not exist.')
         return None
     bite = Bite.all().filter('omlet_id = ', omlet.key().id()).filter(
         'number =', number).get()
     return bite
コード例 #4
0
ファイル: bitedb.py プロジェクト: xuamyj/amyjxj-infinite
 def list_omlet_until_number(cls, omlet_name, max_number):
     omlet = Omlet.by_name(omlet_name)
     if not omlet:
         print('Tried to find Bite - Omlet does not exist.')
         return None
     bite_query = Bite.all().filter('omlet_id = ', omlet.key().id()).order('number')
     if not max_number:
         return bite_query.run()
     else:
         return bite_query.run(limit = max_number)
     return bite_query
コード例 #5
0
ファイル: eaterdb.py プロジェクト: xuamyj/amyjxj-infinite
 def by_username(cls, omlet_name, username):
     omlet = Omlet.by_name(omlet_name)
     if not omlet:
         print('Tried to find Bite - Omlet does not exist.')
         return None
     user = User.by_name(user_name)
     if not user:
         print('Tried to find Bite - User does not exist.')
         return None
     eater = Eater.all().filter('omlet_id = ', omlet.key().id()).filter(
         'user_id =', user.key().id()).get()
     return eater
コード例 #6
0
ファイル: dbtests.py プロジェクト: xuamyj/amyjxj-infinite
def omlet_bite_test(self):
    test_username = self.user.name
    self.write('<br>username is: ' + test_username)
    user = User.by_name(test_username)
    self.write('<br>user.id() is: ' + str(user.key().id()))

    # # FOR DELETING
    # delete_for_user(self, test_username)

    omlet1 = Omlet.make_omlet(test_username, 'first')
    if omlet1:
        omlet1.put()
    time.sleep(0.5)
    self.write('<br><br>put in omlet called "first" ')
    self.write('<br>list of omlets for this user is ' + string_list_omlet(Omlet.list_username(test_username)))
    self.write('<br>look, the omlet exists: ' + string_omlet(Omlet.by_name('first')))

    self.write('<br><br>this should be empty: ' + string_list_bite(Bite.list_omlet_until_number('first', None)))
    make_bite_noduplicate('first', 'Bite AAAAA')
    time.sleep(0.5)
    make_bite_noduplicate('first', 'This is bite B of omlet1')
    time.sleep(0.5)
    self.write('<br>this should have two bites: ' + string_list_bite(Bite.list_omlet_until_number('first', None)))

    make_bite_noduplicate('first', 'Bite C')
    time.sleep(0.5)
    make_bite_noduplicate('first', 'Bite D, yay')
    time.sleep(0.5)
    make_bite_noduplicate('first', 'Nom, Bite E')
    time.sleep(0.5)
    self.write('<br><br> want up to bite C: ' + string_list_bite(Bite.list_omlet_until_number('first', 3)))
    self.write('<br> want bite D only: ' + string_bite(Bite.by_omlet_number('first', 4)))

    Bite.set_eaten('first', 2)
    time.sleep(0.5)
    self.write('<br>has bite B been eaten? should be yes: ' + string_bite(Bite.by_omlet_number('first', 2)))

    omlet2 = Omlet.make_omlet(test_username, 'second')
    if omlet2:
        omlet2.put()
    time.sleep(0.5)
    omlet3 = Omlet.make_omlet(test_username, 'third')
    if omlet3:
        omlet3.put()
    time.sleep(0.5)
    omlet4 = Omlet.make_omlet(test_username, 'fourth')
    if omlet4:
        omlet4.put()
    time.sleep(0.5)
    self.write('<br><br>list of omlets for this user should have 4: ' + string_list_omlet(Omlet.list_username(test_username)))
コード例 #7
0
ファイル: bitedb.py プロジェクト: xuamyj/amyjxj-infinite
    def make_bite(cls, omlet_name, text):
        omlet = Omlet.by_name(omlet_name)
        if not omlet:
            print('Tried to make Bite - Omlet does not exist.')
            return None

        latest_bite = Bite.all().filter('omlet_id = ', omlet.key().id()).order('-number').get()
        next_number = 1
        if latest_bite:
            next_number = latest_bite.number + 1;

        return Bite(parent = bites_key(),
                    number = next_number,
                    text = text,
                    eaten = False,
                    omlet_id = omlet.key().id())
コード例 #8
0
ファイル: eaterdb.py プロジェクト: xuamyj/amyjxj-infinite
    def create_eater(cls, omlet_name, username, latest_bite = 0, archived = False):
        omlet = Omlet.by_name(omlet_name)
        if not omlet:
            print('Tried to make Eater - Omlet does not exist.')
            return None
        user = User.by_name(user_name)
        if not user:
            print('Tried to make Eater - User does not exist.')
            return None
        eater = Eater.by_username(omlet_name, username)
        if eater:
            print('Tried to make Eater - Eater already exists.')
            return None

        return Eater(parent = eaters_key(),
                     omlet_id = omlet.key().id(),
                     user_id = user.key().id(),
                     latest_bite = latest_bite,
                     archived = archived)
コード例 #9
0
ファイル: dbtests.py プロジェクト: xuamyj/amyjxj-infinite
def list_all_bites_descending(self, omlet_name):
    omlet = Omlet.by_name(omlet_name)
    all_bites_desc = Bite.all().filter('omlet_id = ', omlet.key().id()).order('-number').run()
    self.write('<br><br>this should list all bites descending: ' + string_list_bite(all_bites_desc))