Esempio n. 1
0
 def handle_search():
     lines = data
     p_start_loc = int(data[0])
     t_start_loc = int(data[1])
     needles = cPickle.loads(wikiutil.unquoteFilename(''.join(data[2:])))
     process_search(needles, wiki_name, client, p_start_loc, t_start_loc)
     client.close()
Esempio n. 2
0
        def process(self):
            import socket, cPickle
            encoded_terms = wikiutil.quoteFilename(
                cPickle.dumps(self.needle_as_entered, True))
            server_address, server_port = config.remote_search
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
            s.connect((server_address, server_port))

            output = s.makefile('w', 0)
            output.write('F\n')
            if self.wiki_global:
                output.write('*\n\n')
            else:
                output.write('%s\n\n' % self.request.config.wiki_name)
            output.write('S\n%s\n%s\n' % (self.p_start_loc, self.t_start_loc))
            output.write('%s\n' % encoded_terms)
            output.write('\n')
            output.write('E\n\n') # end
            output.close()

            input = s.makefile('r', 0)
            for line in input:
                results_encoded = line.strip()
                break

            title_results, text_results, spelling_suggest = cPickle.loads(
                wikiutil.unquoteFilename(results_encoded))

            s.close()

            self.title_results = title_results
            self.text_results = text_results
            self._spelling_suggestion = spelling_suggest
Esempio n. 3
0
    def run(self):
        from Sycamore import wikiacl
        had_error = False
        _ = self.getText
        #self.open_logs()
        if self.isForbidden():
            self.status = "403 FORBIDDEN"
            self.http_headers([('Content-Type', 'text/plain')])
            self.write('You are not allowed to access this!\n')
            return self.finish()

        if not self.wiki_exists:
             self.write('<html><head>'
                '<meta name="robots" content="noindex,follow"></head><body>')
             wiki_name = self.config.name 
             if type(config.wiki_farm_no_exist_msg) == tuple:
                msg, items_string = config.wiki_farm_no_exist_msg
                items = eval(items_string)
                no_exist_msg = msg % items
             else:
                no_exist_msg = config.wiki_farm_no_exist_msg
             self.write(no_exist_msg)
             self.write('</body></html>')
             return self.finish()
        elif (self.config.is_disabled and not
            self.user.name in wikiacl.Group("Admin", self)):
             self.write('<html><head>'
                '<meta name="robots" content="noindex,follow"></head><body>')
             self.write('<p>The wiki %s has been disabled and will be '
                        'permanently deleted in 30 days.</p>' % 
                        self.config.wiki_name)
             self.write('</body></html>')
             return self.finish()

        # parse request data
        try:
            from Sycamore.Page import Page
            self.args = self.setup_args()
            self.form = self.args 
            path_info = self.getPathinfo()

            #from pprint import pformat
            #sys.stderr.write(pformat(self.__dict__))
    
            action = self.form.get('action',[None])[0]

            pagename = None
            oldlink = None
            if len(path_info) and path_info[0] == '/':
                pagename = wikiutil.unquoteWikiname(path_info[1:])
                oldlink = wikiutil.unquoteFilename(path_info[1:])

            pagename = self.recodePageName(pagename)
            oldlink = self.recodePageName(oldlink)
            self.pagename = pagename

            # if oldlink has control characters when we do an mc_quote -- eep!
            # we want to, then, throw it out because it wasn't going to work
            if (not oldlink or not
                wikiutil.suitable_mc_key(oldlink.encode(config.charset))):
               oldlink = ''

            pagename_propercased = ''
            oldlink_propercased = ''
            if pagename: 
                pagename_exists_name = Page(pagename, self).exists()
                if pagename_exists_name:
                    pagename_propercased = pagename_exists_name
                if oldlink:
                    oldlink_exists_name = Page(oldlink, self).exists()
                    if oldlink_exists_name:
                        oldlink_propercased = oldlink_exists_name

                if pagename_propercased:
                    self.pagename_propercased = pagename_propercased
                else:
                    self.pagename = pagename

                if self.pagename.endswith('/'):
                    pagename = self.pagename[:-1]
                    while pagename.endswith('/'):
                        pagename = pagename[:-1]
                    url = Page(pagename, self).url(relative=False)
                    self.http_redirect(url, status="301 MOVED PERMANENTLY")
 
        except Page.ExcessiveLength, msg:
            Page(self.config.page_front_page, self).send_page(msg=msg)
            return self.finish()
Esempio n. 4
0
 def handle_delete():
     client.close()
     pagename = wikiutil.unquoteFilename(data[0])
     spool_lock.acquire()
     spool.mark_for_remove((pagename, wiki_name))
     spool_lock.release()