[Zope-dev] Yet more unicode and page template weirdness

2010-10-13 Thread Chris Withers
Hi All,

In Zope 2.12, try putting the following in a TTW ZPT:

tal:c content=#8250;/

...nothing more, nothing less.

On save, I get:

Compilation failed
type 'exceptions.UnicodeEncodeError': 'ascii' codec can't encode 
character u'\u203a' in position 0: ordinal not in range(128)

If I try and view the template, unsurprisingly, I get:

Module ZPublisher.Publish, line 127, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 47, in call_object
Module Shared.DC.Scripts.Bindings, line 324, in __call__
Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
Module Products.PageTemplates.ZopePageTemplate, line 335, in _exec
Module Products.PageTemplates.ZopePageTemplate, line 432, in pt_render
Module Products.PageTemplates.PageTemplate, line 80, in pt_render
Module zope.pagetemplate.pagetemplate, line 109, in pt_render
Warning: Compilation failed
Warning: type 'exceptions.UnicodeEncodeError': 'ascii' codec can't 
encode character u'\u203a' in position 0: ordinal not in range(128)
PTRuntimeError: ['Compilation failed', type 
'exceptions.UnicodeEncodeError': 'ascii' codec can't encode character 
u'\\u203a' in position 0: ordinal not in range(128)]

Any ideas where the non-ascii character is in the above?

cheers,

Chris

-- 
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
___
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 )


Re: [Zope-dev] Yet more unicode and page template weirdness

2010-10-13 Thread Charlie Clark
Am 13.10.2010, 09:53 Uhr, schrieb Chris Withers ch...@simplistix.co.uk:

 Any ideas where the non-ascii character is in the above?

Either this is a trick question or I'm just not getting it.

203a is the hex value of the decimal 8250.

 hex(8250)
'0x203a'

Maybe your question is actually why is the XML entity being converted to  
character data at all?

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting  Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
___
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 )


Re: [Zope-dev] Yet more unicode and page template weirdness

2010-10-13 Thread Chris Withers
On 13/10/2010 11:19, Charlie Clark wrote:
 Maybe your question is actually why is the XML entity being converted to
 character data at all?

I guess so...

My naive experience is that this just works in Zope 2.9 and just 
breaks in 2.12.

 Maybe your question is actually why is the XML entity being converted to
 character data at all?

Yes, absolutely :-)

Chris

-- 
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
___
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 )


Re: [Zope-dev] Yet more unicode and page template weirdness

2010-10-13 Thread Marius Gedminas
On Wed, Oct 13, 2010 at 08:53:08AM +0100, Chris Withers wrote:
 Hi All,
 
 In Zope 2.12, try putting the following in a TTW ZPT:
 
 tal:c content=#8250;/

Are you sure you didn't mean

  tal:c content=string:#8250;/

?  Because I am pretty sure your TALES namespace does not contain
a variable named ›.

 ...nothing more, nothing less.
 
 On save, I get:
 
 Compilation failed
 type 'exceptions.UnicodeEncodeError': 'ascii' codec can't encode 
 character u'\u203a' in position 0: ordinal not in range(128)
...
 Any ideas where the non-ascii character is in the above?

#8250; is the non-ASCII character, obviously.

The way XML works, all entities in an attribute value are decoded before
being interpreted, so your TALES interpreter gets an expression
u'\u203a' which it then fails to interpret.

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3/BlueBream consulting and development


signature.asc
Description: Digital signature
___
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 )


Re: [Zope-dev] Yet more unicode and page template weirdness

2010-10-13 Thread Chris Withers
On 13/10/2010 13:47, Marius Gedminas wrote:
 On Wed, Oct 13, 2010 at 08:53:08AM +0100, Chris Withers wrote:
 Hi All,

 In Zope 2.12, try putting the following in a TTW ZPT:

 tal:c content=#8250;/

 Are you sure you didn't mean

tal:c content=string:#8250;/

Ah, d'oh! Thanks for the catch!

 The way XML works, all entities in an attribute value are decoded before
 being interpreted, so your TALES interpreter gets an expression
 u'\u203a' which it then fails to interpret.

Makes sense, thanks! What about entities outside of attributes?

Chris

-- 
Simplistix - Content Management, Batch Processing  Python Consulting
 - http://www.simplistix.co.uk
___
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 )


Re: [Zope-dev] Yet more unicode and page template weirdness

2010-10-13 Thread Marius Gedminas
On Wed, Oct 13, 2010 at 01:56:58PM +0100, Chris Withers wrote:
 On 13/10/2010 13:47, Marius Gedminas wrote:
  On Wed, Oct 13, 2010 at 08:53:08AM +0100, Chris Withers wrote:
  In Zope 2.12, try putting the following in a TTW ZPT:
 
  tal:c content=#8250;/
 
  Are you sure you didn't mean
 
 tal:c content=string:#8250;/
 
 Ah, d'oh! Thanks for the catch!
 
  The way XML works, all entities in an attribute value are decoded before
  being interpreted, so your TALES interpreter gets an expression
  u'\u203a' which it then fails to interpret.
 
 Makes sense, thanks! What about entities outside of attributes?

You're absolutely right, 

  #8250;

is a much more straightforward way to insert that character than

  tal:c content=string:#8250;/

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3/BlueBream consulting and development


signature.asc
Description: Digital signature
___
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 )