Skip to content

Instantly share code, notes, and snippets.

@robinedwards
Created December 6, 2012 12:38
Show Gist options
  • Save robinedwards/4224179 to your computer and use it in GitHub Desktop.
Save robinedwards/4224179 to your computer and use it in GitHub Desktop.
@classmethod
def lookup(cls, uid=None):
lang = translation.get_language().replace('-', '_')
query = """
START lang = node:Language(code:{lang}),
node = node:%s(uid:{uid})
MATCH (node)-[:LANGUAGE]->(lang)
RETURN node
""" % (cls.__name__)
r = cls.category().cypher(query, {'uid': uid, 'lang': lang})[0]
if r:
return r[0][0]
else:
raise cls.DoesNotExist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment