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

publish error: 'unicode' object has no attribute 'get' #247

Closed
snarfed opened this issue Aug 2, 2014 · 3 comments
Closed

publish error: 'unicode' object has no attribute 'get' #247

snarfed opened this issue Aug 2, 2014 · 3 comments
Assignees
Labels

Comments

@snarfed
Copy link
Owner

snarfed commented Aug 2, 2014

may be related to our recent rel-syndication publish changes. cc @kylewm

from this preview attempt:

Error: 'unicode' object has no attribute 'get'
Traceback (most recent call last):
  File "/base/data/home/apps/s~brid-gy/3.377668401410358947/publish.py", line 153, in post
    resp = self.attempt_single_item(item)
  File "/base/data/home/apps/s~brid-gy/3.377668401410358947/publish.py", line 198, in attempt_single_item
    obj = microformats2.json_to_object(item)
  File "/base/data/home/apps/s~brid-gy/3.377668401410358947/activitystreams/microformats2.py", line 179, in json_to_object
    author = json_to_object(prop.get('author'))
  File "/base/data/home/apps/s~brid-gy/3.377668401410358947/activitystreams/microformats2.py", line 179, in json_to_object
    author = json_to_object(prop.get('author'))
  File "/base/data/home/apps/s~brid-gy/3.377668401410358947/activitystreams/microformats2.py", line 174, in json_to_object
    props = mf2.get('properties', {})
AttributeError: 'unicode' object has no attribute 'get'
@snarfed
Copy link
Owner Author

snarfed commented Aug 2, 2014

interesting. this is happening because of an implicit assumption. when mf2py gives us an author property, we assume it's an object (a dict), but in these two cases, there's an outer author object with an inner author property that's just a list of strings.

is that valid? do i need to handle that? not sure yet. cc @kartikprabhu

here are two examples. mf2py parses this markup from http://www.pierre-o.fr/blog/2014/08/02/permashortlinks/ :

<span class="byline author vcard">
  Posted by <span class="p-author fn">Pierre Ozoux</span>
</span>

and returns this JSON (bridgy log):

{'items': [{
  'type': ['h-entry'],
  'properties': {
    'author': [{
      'type': ['h-card'],
      'properties': {
        'name': [u'Pierre Ozoux'],
        'author': [u'Pierre Ozoux'],
        },
      'value': u'Posted by Pierre Ozoux',
      }],
    'url': ['http://www.pierre-o.fr/s/9.htm'],
    ...

same thing with http://maniaravings.com/blog/2013/12/how-do-you-worship-to-please/ :

<p class="the_author h-card vcard author">
  By <a rel="author" class="fn p-author" href="%20">Jaffer</a>
</p>

mf2py returns this (bridgy log):

{'items': [{
  'type': ['h-entry'],
  'properties': {
    'author': [{
      'type': ['h-card'],
      'properties': {
        'name': [u'Jaffer'],
        'author': [u'Jaffer'],
      },
      'value': u'By Jaffer',
    }],
    'url': ['http://maniaravings.com/blog/2013/12/how-do-you-worship-to-please/'],
    ...

@snarfed
Copy link
Owner Author

snarfed commented Aug 2, 2014

cc @pierreozoux since he hit this recently. sorry pierre, we should have it fixed soon!

@snarfed
Copy link
Owner Author

snarfed commented Aug 2, 2014

@kartikprabhu says to ignore the inner author property. easy to do. thanks kartik!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant