当我在NeoModel,Python中使用RelationshipFrom()方法时,得到KeyError:' __ file __'

时间:2013-10-02 10:39:57

标签: python neo4j neomodel

我正在尝试使用Python,Neo4j,NeoModel和Heroku制作Web服务器。因为我不熟悉NeoModel,所以我现在正试着向Github NeoModel Basic tutorial学习。我编译这段代码时遇到了麻烦。

from neomodel import (StructuredNode, StringProperty, IntegerProperty,
    RelationshipTo, RelationshipFrom)

class Country(StructuredNode):
    code = StringProperty(unique_index=True, required=True)

    # traverse incoming IS_FROM relation, inflate to Person objects
    inhabitant = RelationshipFrom('Person', 'IS_FROM')


class Person(StructuredNode):
    name = StringProperty(unique_index=True)
    age = IntegerProperty(index=True, default=0)

    # traverse outgoing IS_FROM relations, inflate to Country objects
    country = RelationshipTo(Country, 'IS_FROM')

我收到了这个错误,

Traceback (most recent call last):
  File "C:\Users\someo_000\Desktop\a.py", line 11, in <module>
    class Person(StructuredNode):
  File "C:\Users\someo_000\Desktop\a.py", line 16, in Person
    country = RelationshipTo(Country, 'IS_FROM')
  File "build\bdist.win32\egg\neomodel\relationship_manager.py", line 287, in RelationshipTo
    return _relate(cls_name, OUTGOING, rel_type, cardinality, model)
  File "build\bdist.win32\egg\neomodel\relationship_manager.py", line 283, in _relate
    return RelationshipDefinition(rel_type, cls_name, direction, cardinality, model)
  File "build\bdist.win32\egg\neomodel\relationship_manager.py", line 218, in __init__
    self.module_file = sys._getframe(4).f_globals['__file__']
KeyError: '__file__'

我正在尝试使用Heroku和本地服务器执行此操作 我在两种情况下都在cmd中设置NEO4J_REST_URL环境变量。 在这两种情况下,我都有同样的错误。

如果我删除这两行

inhabitant = RelationshipFrom('Person', 'IS_FROM')
country = RelationshipTo(Country, 'IS_FROM')

我认为它运作良好。

谢谢你的阅读!

0 个答案:

没有答案