Exemple #1
0
 def get(self, url):
     navigation = get_current_navigation(self, url)
     version = self.request.get('v')
     if version:
         #query version number
         page_and_time = get_page_and_time(url)
         page = page_and_time[0]
         log(page_and_time[0].content)
         found_version = False
         for page_version in page.page_versions:
             if page_version.version_number == version:
                 page_and_time[0] = page_version
                 log(page_version.content)
                 found_version = True
                 break
         log(page_and_time[0].content)
         if not found_version:
             page_version = None
         self.write_form(page_and_time, navigation)
     else:
         page_and_time = get_page_and_time(url)
         if page_and_time is None:
             # page does not exist redirect to create it!
             self.redirect("/wiki/_edit%s" % str(url))
         else:
             self.write_form(page_and_time, navigation)
Exemple #2
0
 def get(self,url):
     navigation = get_current_navigation(self,url)
     version = self.request.get('v')
     if version:
         #query version number
         page_and_time  = get_page_and_time(url)
         page = page_and_time[0]
         log(page_and_time[0].content)
         found_version = False
         for page_version in page.page_versions:
             if page_version.version_number == version:
                 page_and_time[0] = page_version
                 log(page_version.content)
                 found_version = True
                 break
         log(page_and_time[0].content)
         if not found_version:
             page_version = None
         self.write_form(page_and_time,navigation)
     else:
         page_and_time  = get_page_and_time(url)
         if page_and_time is None:
             # page does not exist redirect to create it!
             self.redirect("/wiki/_edit%s" % str(url)) 
         else:
             self.write_form(page_and_time,navigation)
Exemple #3
0
 def post(self, url):
     # check if page already exists if thats not the case create new page else update data
     page_and_time = get_page_and_time(url)
     page_content = self.request.get('content')
     page_url = url
     page = None
     if page_and_time is None:  # new page!
         page = Page(key_name=page_url,
                     content=page_content,
                     version_number=1)
         page.put()
         # add it to memcache
         cache_hit_time = time.time()
         page_and_time = [page, cache_hit_time]
         if not memcache.add('page_and_time' + page_url, page_and_time):
             loggin.error('Memcache and failed')
     else:  # edit old page
         page = page_and_time[0]
         # update new version
         page.content = page_content
         try:
             page.version_number = page.version_number + 1
         except:
             page.version_number = 1
         page.put()
         cache_hit_time = time.time()
         page_and_time_new = [page, cache_hit_time]
         if not memcache.set('page_and_time' + page_url, page_and_time_new):
             loggin.error('Memcache set failed')
     save_version(page)
     #redirect to new url
     self.redirect("/wiki%s" % str(page.key().name()))
Exemple #4
0
 def post(self,url):
     # check if page already exists if thats not the case create new page else update data
     page_and_time = get_page_and_time(url)
     page_content = self.request.get('content')
     page_url = url
     page = None
     if page_and_time is None: # new page!
         page = Page(key_name = page_url, content = page_content, version_number = 1)
         page.put() 
         # add it to memcache
         cache_hit_time = time.time()
         page_and_time = [page,cache_hit_time]
         if not memcache.add('page_and_time'+page_url,page_and_time):
             loggin.error('Memcache and failed')
     else: # edit old page
         page = page_and_time[0]
         # update new version
         page.content = page_content
         try:
             page.version_number = page.version_number + 1
         except:
             page.version_number = 1
         page.put()
         cache_hit_time = time.time()
         page_and_time_new = [page,cache_hit_time]
         if not memcache.set('page_and_time'+page_url,page_and_time_new):
             loggin.error('Memcache set failed')
     save_version(page)
     #redirect to new url
     self.redirect("/wiki%s" % str(page.key().name()))
Exemple #5
0
    def get(self, url):
        #check if url already exists and show list of versions
        page_and_time = get_page_and_time(url)
        #get navigation bar
        uid = self.read_secure_cookie('user_id')
        user = uid and User.by_id(int(uid))
        navigation = Navigation(user, url)

        if page_and_time is None:
            self.write_form(url, '', navigation)
        else:
            page = page_and_time[0]
            self.write_form(url, page.page_versions, navigation)
Exemple #6
0
 def get(self,url):
     #check if url already exists and show list of versions
     page_and_time = get_page_and_time(url)
     #get navigation bar
     uid = self.read_secure_cookie('user_id')
     user = uid and  User.by_id(int(uid))
     navigation = Navigation(user,url)
     
     if page_and_time is None:
         self.write_form(url,'',navigation)
     else:
         page = page_and_time[0]
         self.write_form(url, page.page_versions,navigation)
Exemple #7
0
    def get(self, url):
        uid = self.read_secure_cookie('user_id')
        u = uid and User.by_id(int(uid))
        if u:
            #check if url already exists and show old contend to edit
            page_and_time = get_page_and_time(url)
            #get navigation bar
            uid = self.read_secure_cookie('user_id')
            user = uid and User.by_id(int(uid))
            navigation = Navigation(user, url)

            if page_and_time is None:
                self.write_form('', navigation)
            else:
                page = page_and_time[0]
                self.write_form(page.content, navigation)
        else:
            self.redirect('/wiki/signup')
Exemple #8
0
 def get(self,url):
     uid = self.read_secure_cookie('user_id')
     u = uid and  User.by_id(int(uid))
     if u:
         #check if url already exists and show old contend to edit
         page_and_time = get_page_and_time(url)
         #get navigation bar
         uid = self.read_secure_cookie('user_id')
         user = uid and  User.by_id(int(uid))
         navigation = Navigation(user,url)
         
         if page_and_time is None:
             self.write_form('',navigation)
         else:
             page = page_and_time[0]
             self.write_form(page.content,navigation)
     else:
         self.redirect('/wiki/signup')