I'm glad to hear you found the solution :)

By the way:

   S_typ = type('')
   U_typ = type(u'')
   if not (type(s) in [S_typ, U_typ]):

can more easily be written:

    if not isinstance(s, basestring):

Best Regards,
-jj

On 5/4/07, durumdara <[EMAIL PROTECTED]> wrote:
>
> Hi!
>
> I found the solution:
>
>     def _ResponseAsString(self, Resp):
>         ps = Resp.content[0]
>         ps = ps.decode('utf-8')
>         return ps
>
>     def _RenderContent(self, Content):
>         c.PageContent = Content
>         self._BuildMenus()
>         rp = render_response('/pagetemplate.myt')
>         return rp
>
>     def _RenderContentFromTemplate(self, Templ):
>         PageContent = render_response(Templ)
>         PageContent = self._ResponseAsString(PageContent)
>         return self._RenderContent(PageContent)
>
>     def _SimpleRender(self):
>         path = dwfmt.ToAscii('/' + self.Controller + '/' + self.Action
> + '.myt')
>         return self._RenderContentFromTemplate(path)
>
>
> These methods working in both of WinXP_HU_Prof, and Win2K3_En_Serv
> machines...
>
> Important: it needed to convert all of the c.xxxx rendering constants
> to unicode like this.
>
> <% ToUnicode(c.PageTitle) %>
>
>
> def ToUnicode(s, encoding = None):
>     '''
>     Converts a string to unicode.
>     '''
>     S_typ = type('')
>     U_typ = type(u'')
>     if not (type(s) in [S_typ, U_typ]):
>         s = str(s)
>     if type(s) == S_typ:
>         if encoding == None:
>             encoding = _Locale["encoding"]
>         s = s.decode(encoding, 'replace')
>     return s
>
> def ToAscii(s, encoding = None):
>     '''
>     Converts a unicode string to ascii.
>     '''
>     S_typ = type('')
>     U_typ = type(u'')
>     if not (type(s) in [S_typ, U_typ]):
>         s = str(s)
>     if type(s) == U_typ:
>         if encoding == None:
>             encoding = _Locale["encoding"]
>         s = s.encode(encoding,'replace')
>     return s
>
> dd
>
> On May 2, 4:37 pm, durumdara <[EMAIL PROTECTED]> wrote:
> > Hi!
> >
> > My problem is that:
> >
> > 1.)
> >
> > I used modpy before pylon, and I have many template that use
> > iso-8859-2 characterset.
> >
> > When I try to render some of them I got this errormessage:
> > Error(UnicodeDecodeError): 'ascii' codec can't decode byte 0xc3 in
> > position 51: ordinal not in range(128)
> > File:   c:\python24\lib\site-packages\myghty-1.1-py2.4.egg\myghty
> > \requestbuffer.py line 367
> > Context:        364:         """
> > 365:         if text is None:
> > 366:             return
> > 367:         self._top.write(unicode(text))
> > 368:
> > 369: class StrRequestBuffer(_RequestBuffer):
> > 370:
> >
> > How to I force myt to it use iso-8859-2 charset?
> > Or I need to convert these sources to encode ansi chars to safe html
> > codes?
> >
> > 2.)
> > How to I encode normal text to html?
> > Example: my pagetitles?
> > % ToHTML(c.PageTitle) %
> >
> > Thanks for your help:
> > dd
>
>
> >
>


-- 
http://jjinux.blogspot.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to