Re: Some suggestions (comments and utf-8, pyarchives_enhanced, config file location)
Ryan Barrett <pyblosxom-6sb6M7qyT/[email protected]> Fri, 3 Oct 2008 09:55:30 -0700 (PDT)
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, 21 Sep 2008, Jörn P. Meier wrote:
> I am in the process of creating a blog using Pyblosxom. I really enjoy working
> with it but I ran into some problems. I tried to fix most of those myself but
> I would like to know if there was some mistake on my part. Also, if those are
> indeed bugs, maybe my changes are helpful.
thank you! it looks like these are indeed improvements. much appreciated!
> 1) comments.py and UTF-8
...
> The first problem is that the comments.js does not actually encode the
> form data as UTF-8 even if it is declared as such, which yields a broken
> preview. I applied the following fix:
>
> @@ -66,7 +66,8 @@
> for (i = 0; i < form.elements.length; i++) {
> elem = form.elements[i];
> if (elem.type != 'submit' && elem.type != 'button')
> - post_data += '&' + elem.name + '=' + escape(elem.value);
> + post_data += '&' + elem.name + '='
> + + encodeURIComponent(elem.value);
> }
ah, interesting. thanks!
i don't follow javascript and browser compatibility much, so i don't know how
widely supported encodeURIComponent() is. do you? if it is widely supported, i'm
ok with this. otherwise, we'd need to do something else.
let's see...
http://www.google.com/search?q=encodeuricomponent+browser+support
points to e.g.
http://burstproject.org/tests/testbrowser/browser_bugs.html
which says it's mostly supported in modern browsers, but not in e.g. ie 5 on
pc, ie 5 on mac, safarai (ie webkit) 1.x or konqueror before 3.2.
does anyone else on the list have thoughts on how much we should pay attention
to browser compatibility in plugin javascript?
> The second problem is that in comments.py, there is a section where values
> from the form are passed (via tools.urlencode_text) to urllib.quote, which
> tries to use the ASCII codec by default if an unicode string is passed. This
> fails if the unicode string actually contains a character that cannot be
> encoded in ASCII. My fix tries to encode the string using UTF-8 before it is
> passed if it is a unicode string.
...
> Maybe it is not so good an idea to hardcode the encoding. Unfortunately
> I do not understand the code well enough yet to come up with a better
> solution. However, this works in my setup.
thanks! this is a good change. i've modified it to use the encoding specified
in config.py, defaulting to uft-8. i've checked that into head:
http://pyblosxom.svn.sourceforge.net/viewvc/pyblosxom?view=rev&revision=1273
would you mind testing it to see if it works for you?
on a related note, will has proposed that pyblosxom 2.0 be all utf-8, all the
time:
http://pyblosxom.sourceforge.net/wiki/index.php/UTF8
> I also modified pyblosxom.py to make the configuration file location
> configurable:
>
> @@ -445,7 +443,8 @@
> """
> This class is the WSGI application for PyBlosxom.
> """
> - def __init__(self, environ=None, start_response=None, configini=None):
> + def __init__(self, environ=None, start_response=None, configini=None,
> + configpy = None):
> """
> Make WSGI app for PyBlosxom.
>
> @@ -465,10 +464,12 @@
> configini = {}
>
> _config = tools.convert_configini_values(configini)
> -
> - # FIXME - what if config is not named config?
> - import config
> - self.config = dict(config.py)
> +
> + if (configpy is None):
> + configpy = 'config.py'
> + gl = {}
> + execfile(configpy, gl)
> + self.config = dict(gl['py'])
>
> This uses config.py if no file has been specified when the application was
> created. Otherwise, it loads whatever file has been specified. I notice
> there is an configini argument, but using an INI file when I can use Python
> just seems awkward. ;)
interesting idea! will, do you have any thoughts on this?
-Ryan
--
http://snarfed.org/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel