Hi,

Sorry, I've been out the past week so I haven't been around to offer much
advice here.

I'm glad you found a solution. I think we need a better way to factor this
all out, though. Otherwise you'll have to maintain a custom patch for every
upgrade.

Can you tell me where you placed the first bit of code (encoding
changeset0['desc'])?

We probably can reuse the repository's Encoding field and insert the lines
into perforce.py to respect it, in much the same way that you did. So
instead of unicode(something, 'cp949'), it'd be unicode(something,
repository.encoding). Right now, that field only appears to affect the
patches.

And in your case, what does p4.charset show?

Christian

-- 
Christian Hammond - chip...@chipx86.com
Review Board - http://www.reviewboard.org
VMware, Inc. - http://www.vmware.com


2011/4/10 jh5774....@samsung.com <jh5774....@samsung.com>

> Well, well,
>
> I finally solve this problems.
>
> previous code, p4 description string problem, I change "euc-kr" to
> "cp949" for resolve some combination of 'Korean'
>
> if not self.p4.charset:
>         if changeset:
>                  changeset0['desc'] = unicode(changeset0['desc'],
> 'cp949').encode('utf-8')
>
> And, When I select 'diff viewer', original file and new 's comment
> line broken problem also resolve('Korean comment').
>
> 1. Original file's broken.:
>
> /usr/local/lib/python2.6/dist-packages/ReviewBoard-1.5.4-py2.6.egg/
> reviewboard/scmtools/perforce.py
>
> class PerforceTool(SCMTool):
> ...
> def get_file(self, path, revision=HEAD):
>      ...
>      p = subprocess.Popen(cmdline, stdout=subprocess.PIPE,
> stderr=subprocess.PIPE)
>      (res, errdata) = p.communicate()
>      if res:
>              res = unicode(res, 'cp949').encode('utf-8')   # This is
> that line.
>
> 2. New file's broken:
>
> /usr/local/lib/python2.6/dist-packages/ReviewBoard-1.5.4-py2.6.egg/
> reviewboard/diffviewer/diffutils.py
>
> ...
> def patch(diff, file, filename):
> ...
>
> (fd, oldfile) = tempfile.mkstemp(dir=tempdir)
> f = os.fdopen(fd, "w+b")
> f.write(convert_line_endings(file))
>
> f.close()diff = unicode(diff,'cp949').encode('utf-8')   # This line is
> that line.
> diff = convert_line_endings(diff)
>
> Thank you everyone,
> Especially special thanks to : Chris Clark, and Minwoo Lee :)
>
>
>
>
> On 4월10일, 오후6시05분, "jh5774....@samsung.com" <jh5774....@samsung.com>
> wrote:
> > Well, I find solution about my problems....
> >
> > I'm adding codes to
> >
> > /usr/local/lib/python2.6/dist-packages/ReviewBoard-1.5.4-py2.6.egg/
> > reviewboard/scmtools/perforce.py
> >
> > class PerforceTool(SCMTool):
> > ...
> > ...
> >    def get_changeset(self, changesetid):
> > ....
> >       if not self.p4.charset: # this if sentence needs more test in
> > future.
> >               changeset[0]['desc'] = unicode(changeset[0]['desc'],
> > 'euc-kr').encode('utf-8')
> >
> > And, my repository's encode's value set 'empty'.
> >
> > And, I revert my sitecustomize.py to original.
> >
> > But, now, there's another problem is occured.
> >
> > If I add diff file, they also 'Korean' is broken.
> >
> > Well... I'm tired today.
> >
> > But, Thank you who help me.
> >
> > Have a nice day~!!
> >
> > On 4월9일, 오후5시01분, "jh5774....@samsung.com" <jh5774....@samsung.com>
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Well,
> >
> > > I appliy it to sitecustomize.py like below:
> >
> > > import sys
> > > sys.setdefaultencoding('euc-kr')
> >
> > > Then, my reviewboard's error message is changed. Only that.
> >
> > > before:
> > > JSONEncoderAdapter.encode: Arguments are:  {'stat': 'ok',
> > > 'review_request': <ReviewRequest: [Bad Unicode data]>}
> >
> > > after:
> > > JSONEncoderAdapter.encode: Arguments are:  {'stat': 'ok',
> > > 'review_request': <ReviewRequest: test ㅏㅁ너아ㅏㅓ test>}
> >
> > > actually, there's no korean, but weird sign in <ReviewRequest: ...>
> >
> > > And, I try to find response data when rb request to perforce.
> >
> > > in
> > >  /usr/local//lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/
> > > core/handlers/base.py
> >
> > > class BaseHandler(object):
> >
> > >    def get_response(self, request):
> >
> > > # I think here is that function.
> >
> > > try:
> > >              # Apply response middleware, regardless of the response
> > >              for middleware_method in self._response_middleware:
> > >                  response = middleware_method(request, response)
> >
> > > The exception is occurred in this sentence.
> >
> > > But, I cannot trace more.
> >
> > > I need someone's help.
> >
> > > Thank you.
> >
> > > On 4월9일, 오전1시02분, Chris Clark <chris.cl...@ingres.com> wrote:
> >
> > > > jh5774....@samsung.com wrote:
> > > > > Well, I found a little clue about encoding.
> >
> > > > > /usr/lib/python2.6/json/__init__.py
> >
> > > > > in this codes, they said python only decode 'ASCII' and 'Unicode'.
> >
> > > > > So, python couldn't decode when encounter like a 'Korean word'
> >
> > > > > I find some solution about decoding.
> >
> > > > > For example,
> >
> > > > >     a= '테스트'
> > > > >     unicodeA =a.decode('euc-kr')
> > > > >     utf8A = unicodeA.encode('utf-8')
> >
> > > > > or
> > > > >     u = unicode(a, 'euc-kr').encode('utf-8')
> >
> > > > > Now, I must find the where reviewboard receive response message
> > > > > which their request to perforce using 'p4 describe' command.
> >
> > > > > Anyone who knows about that, please tell me.
> >
> > > > I'd be tempted to take a look at postreview and look at adding an
> > > > encoding flag. I haven't yet really looked at the transport
> mechanism,
> > > > there is a string implication that Unicode (specifically utf8) is
> sent
> > > > for the diffs, really bytes should be sent. This may be because json
> is
> > > > supposed to be utf8. Basically you would do the first part of your
> > > > example above in postreview. The other option (and this is a hack) is
> to
> > > > change your site packages to change the default system encoding for
> > > > Python from ASCII (default for windows) to euc-kr. This normally
> isn't
> > > > recommended BUT it would be a good diagnostic step to take to
> > > > prove/disprove the theory.  Seehttp://
> blog.ianbicking.org/illusive-setdefaultencoding.html
> >
> > > > Let us know how you get on.
> >
> > > > The extreme solution would be to use utf8 encoding for all source
> code,
> > > > which is fine for new projects but more tricky for older projects.
>
> --
> Want to help the Review Board project? Donate today at
> http://www.reviewboard.org/donate/
> Happy user? Let us know at http://www.reviewboard.org/users/
> -~----------~----~----~----~------~----~------~--~---
> To unsubscribe from this group, send email to
> reviewboard+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/reviewboard?hl=en
>

-- 
Want to help the Review Board project? Donate today at 
http://www.reviewboard.org/donate/
Happy user? Let us know at http://www.reviewboard.org/users/
-~----------~----~----~----~------~----~------~--~---
To unsubscribe from this group, send email to 
reviewboard+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/reviewboard?hl=en

Reply via email to