[Silva-general] How to pass parameters to kupu spellchecker?

Nico Grubert nicogrubert at gmail.com
Wed Mar 29 14:23:04 CEST 2006


Dear Silva developers,

is it possible to pass additional parameters to the 'check()' method 
defined in '\Products\kupu\python\spellchecker.py'?

Right now, it reads:

def check(self, text):
     """checks a line of text
        ...
     """

I would like to pass a parameter 'txtencoding' so I changed this method 
a little bit:

def check(self, txtencoding='iso-8859-15'):
     """checks a line of text
        ...
     """

After I changed the spellchecker.py script, I restarted Zope.

Then, I looked through the sources, where 'check()' is called.
The only place where the 'send()' method is called I found at 
'\Products\kupu\common\kupuspellchecker.js' where it reads:

  KupuSpellChecker.prototype.check = function() {
   var request = new XMLHttpRequest();
   request.open('POST', this.scripturl, true);
   request.setRequestHeader('Content-Type',
                             'application/x-www-form-urlencoded');
   request.onreadystatechange = new ContextFixer(
                                    this.stateChangeHandler,
                                    this,
                                    request).execute;
   var result = this.getCurrentContents();
   result = escape(result.strip().replace('\n', ' ').reduceWhitespace());
   request.send('text=' + result);
   };
          ^^^^^^^^^^^^^^^^^^^^^^^

To pass the new parameter 'txtencoding' to my modified 'check()' method 
I changed the line 'request.send('text=' + result);' in kupuspellchecker.js:
I tried
   request.send('text=' + result + '&txtencoding=utf-8');
and
   request.send('text=' + result, 'txtencoding=utf-8');

Unfortunately, both don't work! :-(
It seems that the 'txtencoding' parameter is never passed to 'check()' 
because I always get the default value 'iso-8859-15' instead of 'utf-8'.


Any idea, how I can pass additional parameters to the 'check()' method?


Kind regards,
Nico



More information about the Silva-general mailing list