Re: [Zope-dev] UnicodeDecodeError from PageTemplate rendering after upgrading to Zope 2.12.7

2010-08-31 Thread Robert Casties
Hi Chris,

On 08/31/2010 11:40 AM, Chris Withers wrote:
> After a recent upgraded to Zope 2.12, I'm now seeing errors like the 
> following when using IE (version 8) or Safari (version 4.0.3) to view 
> page templates. Chrome and Firefox work fine.

This may be related to IE and Safari not sending an accept-charset
header and Zope then falling back to the Python default (often ASCII)
for encoding, which then fails.

I use the following patch to http.py (tested up to 2.12.3):

--- lib/python/zope/publisher/http.py.orig  2009-05-02
00:49:35.0 -0700
+++ lib/python/zope/publisher/http.py   2009-06-12 02:12:50.0 -0700
@@ -965,8 +965,11 @@
 # value of 1 if not explicitly mentioned.
 # And quoting RFC 2616, $14.2: "If no Accept-Charset header is
 # present, the default is that any character set is acceptable."
-if not sawstar and not sawiso88591 and header_present:
+# ROC: the following checked also for header_present which
seemed wrong
+if not sawstar and not sawiso88591:
 charsets.append((1.0, 'iso-8859-1'))
+# ROC: if there is no header we assume star (to get utf-8)
+sawstar = 1
 # UTF-8 is **always** preferred over anything else.
 # Reason: UTF-8 is not specific and can encode the entire unicode
 # range , unlike many other encodings. Since Zope can easily
use very


Best
Robert


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Solved!, was: Re: Escaping special characters in ZCTextIndex.QueryParser?

2007-11-28 Thread Robert Casties
mustapha wrote:
> 
> Robert Casties wrote:
>> Enclosing the words with double quotes has not helped, neither have
>> backslashes...
> 
> You have to enclose  your string with double quotes and then with single
> quote. So the parser gets the double quotes with the search string
> The parser does not interpret the string between double quotes.

Ok, it was my fault :-(

The query parser does not interpret expressions in double quotes, it was
my special splitter that got called from the QueryParser (I didn't know
that the QueryParser does that) that split and deleted all parentheses
before the actual search.

Now I have changed my splitter and it works as expected.

Thanks a lot

Robert

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: Escaping special characters in ZCTextIndex.QueryParser?

2007-11-27 Thread Robert Casties
Dieter Maurer wrote:
> Robert Casties wrote at 2007-11-25 19:32 +0100:
>> is it possible to escape parentheses in ZCTextIndex searches?
>>
>> If not, why not and how can I do a simple search in an index bypassing
>> the QueryParser?
> 
> I fear nobody of us knows this.
> 
> Therefore, you must yourself look at the sources.

I had a quick look at the QueryParser source before but it wasn't
obvious to me. I will have a deeper look again.

> If you need this feature and "ZCTextIndex" does not provide
> it, then you may use a different text index.
> I know that with "TextIndexNG3" you can select different
> parsers (among others a parser that does not interpret '(' and ')')
> or provide your own one.

Is the parser for the search query also pluggable? I will have another
look at TextIndexNG.

>> I have an index where words can contain parentheses and I am unable to
>> enter a query for these words because the QueryParser interprets all
>> parentheses as search expression groupings.
> 
> Then, you will need to change the lexicon as well.
> Usually, the lexicon breaks words at non alnum characters
> (with a few exeptions).

I have my own splitter for the Lexicon so I think the right words are in
the index but I haven't been able to check because I can't search the
index...


Thanks
Robert

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Escaping special characters in ZCTextIndex.QueryParser?

2007-11-25 Thread Robert Casties
Hi,

is it possible to escape parentheses in ZCTextIndex searches?

If not, why not and how can I do a simple search in an index bypassing
the QueryParser?

I have an index where words can contain parentheses and I am unable to
enter a query for these words because the QueryParser interprets all
parentheses as search expression groupings.

Enclosing the words with double quotes has not helped, neither have
backslashes...

Is there a way other than having to write a new ZCTextIndex?

Thanks for any insight

Robert

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )