question on encoding

View: New views
2 Messages — Rating Filter:   Alert me  

question on encoding

by 오종암 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My kid.encoding is 'utf-8', so everything have been good work.
but My turbogears app must be connected in another machine that knows only 'euc-kr' encoding.
so I want to know how to encode only one function to 'euc-kr' in my controller.py, but others are 'utf-8'
 
this is my controller.py
class Root(controllers.RootController):
  @expose(template="ucsrv.templates.devlist")#this function's encoding is utf-8
    def index(self):
      return dict(lineDevs = UCApp.singleton.lineDevs,telLineDevs=UCApp.singleton.telLineDevs)
 
  @expose(template="ucsrv.templates.euc_kr")#this function's encoding is euc-kr
  def toAnotheMachine(self):
    return dict(lang='Korean",contents="blurblur")
 
 
I want to convert just 'toAnotheMachine' function's encoding to 'euc-kr' exception 'index' function.
Is this possible?
How can I do this?
 
Thank you in advance for your oppinion!
 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: question on encoding

by Christoph Zwerschke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


오종암 schrieb:

> My kid.encoding is 'utf-8', so everything have been good work.
> but My turbogears app must be connected in another machine that knows
> only 'euc-kr' encoding.
> so I want to know how to encode only one function to 'euc-kr' in my
> controller.py, but others are 'utf-8'
>  
> ...
>  
> I want to convert just 'toAnotheMachine' function's encoding to 'euc-kr'
> exception 'index' function.
> Is this possible?
> How can I do this?

You need to set up a euc_kr serializer for Kid, like so:

import kid
euc_kr = kid.HTMLSerializer(encoding='euc-kr')

Then you can expose your controller like that:

@expose(template="...", format=euc_kr)

In your app.cfg you must also set kid.encoding=None, because otherwise
the kid.encoding will override your serializer's encoding.

On tg-trunk we're just discussing an improvement of TG's Buffet
interface that will allow overloading engine options at render time.
It then will be possible to do something like

@expose(template="...", options={'kid.encoding': 'euc-kr'})

But that is currently not yet possible.

-- Christoph

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbogears@...
To unsubscribe from this group, send email to turbogears+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price!