Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To support UNICODE xblock.location #6167

Merged
merged 1 commit into from
Mar 16, 2015
Merged

To support UNICODE xblock.location #6167

merged 1 commit into from
Mar 16, 2015

Conversation

fmyzjs
Copy link
Contributor

@fmyzjs fmyzjs commented Dec 7, 2014

Ticket: OSPR-269

When people use unicode course org name(e.g Chinese) ,urllib.quote cannot format unicode char like:

>>> import urllib
>>> loc = 'i4x://创联/7302478/chapter/4ab413b41ad9447db41668bed03f149f'
>>> urllib.quote(loc)
'i4x%3A//%E5%88%9B%E8%81%94/7302478/chapter/4ab413b41ad9447db41668bed03f149f'
>>> urllib.quote(unicode(loc))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 6: ordinal not in range(128)
>>> 

so I open this pull
@sarina @nedbat @singingwolfboy

@openedx-webhooks
Copy link

Thanks for the pull request, @fmyzjs! I've created OSPR-269 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • edx-code email threads
  • timeline information ('this must be merged by XX date', and why that is)
  • partner information ('this is a course on edx.org')
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will still be done via the Github pull request interface. As a reminder, our process documentation is here.

@sarina
Copy link
Contributor

sarina commented Dec 8, 2014

I'm unclear if we officially actually support unicode xblock locations - I can't imagine this is the only problem, because we don't have tests around this. @nedbat - do you have any thoughts / can you weigh in?

@fmyzjs this will definitely need tests if we are going to merge this.

@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Dec 8, 2014
@sarina
Copy link
Contributor

sarina commented Dec 9, 2014

@fmyzjs - to be clear I put this PR in the "waiting on author" category because it needs unit tests.

@fmyzjs
Copy link
Contributor Author

fmyzjs commented Dec 11, 2014

@sarina I don't think need tests here. edX officially actually support unicode xblock locations. cms.envs.common.I open this pull because urllib.quote cannot decode unicode url string.

@sarina
Copy link
Contributor

sarina commented Dec 11, 2014

@fmyzjs unit tests will validate this change and ensure we don't break unicode support in the future. This is important because as far as I know, we actively disallow unicode characters in locations on edx.org. So if there are no unit tests, is possible we will break in the future.

def test_unicode_xblock_studio_url(self):

#import unicode course
modulestore = XMLModuleStore(DATA_DIR, course_dirs=['2014_Uni'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes this a Unicode course?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@openedx-webhooks openedx-webhooks added community manager review awaiting prioritization and removed waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. community manager review labels Dec 15, 2014
@sarina
Copy link
Contributor

sarina commented Dec 16, 2014

👍 from me. I'm asking someone from our sustaining team to take a look at this, as well.

@singingwolfboy
Copy link
Contributor

@fmyzjs, there are a lot of commits in here that don't seem related to the work you've done. Could you rebase this pull request, to make sure that it only contains the work that you did?

@adampalay
Copy link
Contributor

@cpennington , do we support unicode in xblock locations? The last I knew, we didn't support unicode org/course/names, but I could be wrong

@cpennington
Copy link
Contributor

I don't think we are yet ready to say that it's fully supported, but I'm happy to see progress towards that front. I believe that opaque_keys in general supports non-ascii characters, so it's just consumers of those keys that will need to adjust, generally.

@adampalay
Copy link
Contributor

so once tests pass, you're cool with this PR?

@cpennington
Copy link
Contributor

Yeah. I guess I don't know what will happen on the other end (whether Studio will get a unicode object from django, or a string object, and whether studio is correctly handling whichever one it does get), so it's probably worth verifying that.

@adampalay
Copy link
Contributor

hi @fmyzjs , may you please rebase this PR?

@adampalay
Copy link
Contributor

👍 once it's rebased

@cpennington
Copy link
Contributor

The example at the top of the PR isn't actually correct usage. In particular:

>>> loc = 'i4x://创联/7302478/chapter/4ab413b41ad9447db41668bed03f149f'
>>> unicode(loc)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 6: ordinal not in range(128)

You can't call unicode on a bytestring (str) object without specifying what the encoding of the bytestring is. The reference to urllib is a red-herring, in the initial example.

@cpennington
Copy link
Contributor

That said:

>>> urllib.quote(u'i4x://创联/7302478/chapter/4ab413b41ad9447db41668bed03f149f')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/urllib.py", line 1288, in quote
    return ''.join(map(quoter, s))
KeyError: u'\u521b'

@cpennington
Copy link
Contributor

👍

@sarina
Copy link
Contributor

sarina commented Feb 18, 2015

@fmyzjs please rebase, and ping us to let us know when you've done that. The PR must be rebased to resolve some conflicts.

@openedx-webhooks openedx-webhooks added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Feb 18, 2015
@sarina
Copy link
Contributor

sarina commented Feb 26, 2015

@fmyzjs - we need you to rebase this PR. If you don't respond within 5 days, we will have to close this PR.

@sarina
Copy link
Contributor

sarina commented Mar 3, 2015

@fmyzjs - please fix quality build (https://build.testeng.edx.org/job/edx-platform-test-subset/5332/artifact/reports/cms/pep8.report/*view*/). Once you are done please comment on the pull request. We do not get notified when you make or update a commit, we only get notified when you tell us it is ready for review.

When people use unicode course org name(e.g Chinese) ,urllib.quote cannot format unicode char like:

```shell
>>> import urllib
>>> loc = 'i4x://创联/7302478/chapter/4ab413b41ad9447db41668bed03f149f'
>>> urllib.quote(loc)
'i4x%3A//%E5%88%9B%E8%81%94/7302478/chapter/4ab413b41ad9447db41668bed03f149f'
>>> urllib.quote(unicode(loc))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 6: ordinal not in range(128)
>>>
```
so I open this pull
@sarina
Copy link
Contributor

sarina commented Mar 16, 2015

@fmyzjs please write a comment on a pull request when you've responded. We don't get notices when you push new commits!

sarina added a commit that referenced this pull request Mar 16, 2015
To support UNICODE xblock.location
@sarina sarina merged commit dadc47c into openedx:master Mar 16, 2015
@sarina
Copy link
Contributor

sarina commented Mar 16, 2015

@fmyzjs we had to revert this commit because it apparently wasn't properly rebased. #7367

Please submit a brand-new pull request with this commit on it once #7367 is merged. Please make sure it is rebased on top of the most recent master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants