Ejemplo n.º 1
0
 def delete_entry(cls, index):
     entry = cls.get_entry(index)
     if not entry:
         return
     entry.is_removed = True
     entry.put()
     PagingCursorMasterKey.clearModelKey("Entry")
Ejemplo n.º 2
0
 def delete_comment(cls, comment):
     entry = comment.entry
     if entry:
         entry.comment_count -= 1
         
         entry.put()
          
     comment.delete()
     PagingCursorMasterKey.clearModelKey("Comment")
Ejemplo n.º 3
0
 def delete_with_user_id(cls, site_user_id):
     query = Comment.all()
     query.filter("site_user_id", site_user_id)
     comments = query.fetch(500, 0)
     
     while comments:
         for comment in comments:
             cls.delete_comment(comment)
             
         query.with_cursor( query.cursor() )
         comments = query.fetch(500, 0 )
         
     PagingCursorMasterKey.clearModelKey("Comment")
Ejemplo n.º 4
0
 def insertUser(cls, user, ip):
     if cls.isUserExist(user) :
         cls.updateLastWrited(user, ip)
         return
     
     new_user = User( google_user_id = user.user_id(),
                      email = user.email(),
                      nickname = user.nickname(),
                      last_ip = ip )
     
     new_user.put()
     PagingCursorMasterKey.clearModelKey("User")
     return new_user 
Ejemplo n.º 5
0
 def delete_with_user_id(cls, site_user_id):
     query = Entry.all()
     query.filter("site_user_id", site_user_id)
     query.filter("is_removed", False)
     entries = query.fetch(500, 0)
     
     while entries:
         for entry in entries:
             entry.is_removed = True
             entry.put()        
             
         query.with_cursor( query.cursor() )
         entries = query.fetch(500, 0 )
         
     PagingCursorMasterKey.clearModelKey("Entry")
Ejemplo n.º 6
0
    def insert(cls, title, link, content, menu_id, user, remote_addr ):
        def txn():
            entry_index = EntryIndex.get_by_key_name('entry')
            if entry_index is None:
                entry_index = EntryIndex(key_name='entry')
            new_index = entry_index.max_index
            entry_index.max_index += 1
            entry_index.put()
            
            
            new_entry = Entry(key_name = 'entry'+str(new_index),
                          parent = entry_index, 
                          index = new_index,
                          title = title,
                          content = content,
                          menu_id = menu_id,
                          user = user,
                          comment_count = 0,
                          ip = remote_addr,
                          link=link,
                          created_on=datetime.datetime.now(),
                          updated_on=datetime.datetime.now())
            new_entry.put()
                        
            return new_entry
        
        if link != "" and link.find("http") == -1 :
            link = "http://" + link

        new_entry = db.run_in_transaction(txn)
        
        site_user_id = User.getSiteUserId(user)
        new_entry.site_user_id = site_user_id
        new_entry.put()
        
        PagingCursorMasterKey.clearModelKey("Entry")
        
        
        return new_entry