I keep getting error from Py2neo: "AttributeError: 'NoneType' object has no attribute 'graph'" when I am trying to create some relations. The weird part is that when I run all lines through the python console - they all complete successfully.
My code (all parameters are strings from HTML forms):
service = Node("service", name=service_name, type=type, features=features_all, options=options_all, qualities=qualities_all, aspects=aspects_all)
graph.create(service)
selecteddomain=matcher.match("domain",domainname=selected_domain).first()
selectedplatform=matcher.match("platform",platformname=selected_platform).first()
service_domain = Relationship(service, "ARRANGED_BY", selecteddomain)
service_platform = Relationship(service, "PART_OF", selectedplatform)
graph.create(service_domain)
graph.create(service_platform)
Exactly the same error I was getting when I was executing the following queries, instead of using the Nodematcher:
domain_query = "MATCH (d:domain) WHERE d.domainname={selected_domain} RETURN d"
selecteddomain = graph.evaluate(domain_query, {"selected_domain": selected_domain})
platform_query = "MATCH (p:platform) WHERE p.platformname={selected_platform} RETURN p"
selectedplatform = graph.evaluate(platform_query, {"selected_platform": selected_platform})
Now - the problem only exists when the selected_platform is made of more than one word in the string. On the selected domain part the problem doesn't exist.
Again - when I try all these on the Python console - they work fine, and the nodes and relations are created.