帮助错误消息

时间:2011-07-15 15:10:18

标签: python django google-app-engine

由于我没有看到我的代码在哪里调用它,因此我无法理解错误消息。使用带有dev_appserver的Google应用引擎的User对象时出现。你能告诉我它意味着什么吗?

ERROR    2011-07-15 15:01:07,664 __init__.py:463] 'User' object has no attribute '_User__email'
Traceback (most recent call last):
  File "/media/Lexar/projects/google/appengine/ext/webapp/__init__.py", line 700, in __call__
    handler.get(*groups)
  File "/media/Lexar/projects/myproject/i18n.py", line 313, in get
    self.response.out.write(template.render(path, template_values))
  File "/media/Lexar/projects/google/appengine/ext/webapp/template.py", line 73, in render
    return t.render(Context(template_dict))
  File "/media/Lexar/projects/google/appengine/ext/webapp/template.py", line 115, in wrap_render
    return orig_render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 809, in render_node
    return node.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/loader_tags.py", line 139, in render
    return self.template.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 809, in render_node
    return node.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/defaulttags.py", line 258, in render
    return self.nodelist_true.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 809, in render_node
    return node.render(context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 849, in render
    return _render_value_in_context(output, context)
  File "/media/Lexar/projects/lib/django_1_2/django/template/__init__.py", line 829, in _render_value_in_context
    value = force_unicode(value)
  File "/media/Lexar/projects/lib/django_1_2/django/utils/encoding.py", line 66, in force_unicode
    s = unicode(s)
  File "/media/Lexar/projects/google/appengine/api/users.py", line 188, in __unicode__
    return unicode(self.nickname())
  File "/media/Lexar/projects/google/appengine/api/users.py", line 152, in nickname
    if (self.__email and self.__auth_domain and
AttributeError: 'User' object has no attribute '_User__email'

编辑:当我删除此代码时,错误消失了:

'user_url': users.create_logout_url(self.request.uri) if users.get_current_user() else 'login','user' : users.get_current_user(),

所以据说我在使用User对象时犯了一些错误

更新:这似乎与我应用的monkeypatch有关。删除此部分会删除错误,因此我想知道是否仍需要此修补程序。据报道

def _user_init(self, email=None, _auth_domain=None,
             _user_id=None, federated_identity=None, federated_provider=None,
             _strict_mode=True):

  if not _auth_domain:
    _auth_domain = os.environ.get('AUTH_DOMAIN')
  assert _auth_domain

  if email is None and federated_identity is None:
    email = os.environ.get('USER_EMAIL', email)
    _user_id = os.environ.get('USER_ID', _user_id)
    federated_identity = os.environ.get('FEDERATED_IDENTITY',
                                        federated_identity)
    federated_provider = os.environ.get('FEDERATED_PROVIDER',
                                        federated_provider)

  if not email and not federated_identity and _strict_mode:
    raise UserNotFoundError

  self.__email = email
  self.__federated_identity = federated_identity
  self.__federated_provider = federated_provider
  self.__auth_domain = _auth_domain
  self.__user_id = _user_id or None

users.User.__init__ = _user_init

monkeypatch来自的相关主题 How do I apply a monkeypatch to GAE?

1 个答案:

答案 0 :(得分:1)

我猜你的错误是在某个模块的导入时间:

ERROR    2011-07-15 15:01:07,664 __init__.py:463] 'User' object has no attribute '_User__email'

__init__.py是将目录定义为模块包的文件。

您可以在其上查找带有User对象的第463行,也可以选择性地删除导入以了解哪个包有问题。

我猜想要修复它,您需要确保User对象确实有_User__email__email} {{1}})属性,但不知道你是如何进行产生错误的电话的,很难说......