Closed Sitin closed 10 years ago
What version of Bulbs are you using?
$ pip freeze | grep bulbs
Scripts are stored in namespaces that correspond to their file name.
All the Bulbs built-in scripts are defined in gremlin.groovy
files so gremlin
is the default namespace.
When you define a Gremlin function in a file named something other than gremlin.groovy
, you need to specify the namespace when getting the script.
For example, in Bulbs 0.3.25 you should be able to do...
>>> from bulbs.rexster import Graph
>>> g = Graph()
>>> g.scripts.update('somefile.groovy')
>>> g.scripts.namespace_map.keys() # list of namespaces
>>> g.scripts.get_methods('somefile') # all methods for the 'somefile' namespace
>>> g.scripts.get("somefile:rank_items") # get script by prefixing the namespace
>>> g.scripts.get("rank_items", "somefile") # get script via the namespace arg
See https://github.com/espeed/bulbs/blob/master/bulbs/groovy.py
Thank you for your answer. I still think that letting the user specify namespaces explicitly is much better. For example:
g.scripts.update('any_file.groovy', namespace='where_i_want_to_put_it')
But this is a Rexter's convention. So, let's consider this as a documentation issue.
You can specify the namespace explicity, i.e. this works...
>>> g.scripts.update('somefile.groovy', namespace='where_i_want_to_put_it')
>>> g.scripts.get("where_i_want_to_put_it:rank_items")
>>> g.scripts.get("rank_items", "where_i_want_to_put_it")
Resolved.
Perfect. Thank you.
Assuming that
rank_items
function defined in both files:The following works, ok:
But the next causing an error:
It seems that file loaded but Gremlin function wasn't added to methods dictionary.