ResourceValue membership testing

A super-tiny SuRF update for today:

import surf
from surf.rdf import URIRef

session = surf.Session(surf.Store())
Person = session.get_class(surf.ns.FOAF)

john_uri = ""
mary_uri = ""

john = Person(john_uri)
mary = Person(mary_uri)

# When setting attribute value, SuRF will wrap it into
# ResourceValue, a list-subclassing object with some 
# extra features.
john.foaf_knows = mary 

print type(john.foaf_knows)
# outputs: <class 'surf.resource.value.ResourceValue'>

print john.foaf_knows
# outputs: [<surf.session.Foaf object at 0x90b746c>]

# Now the new bit:

# Is SuRF resource `mary` in john.foaf_knows?
print mary in john.foaf_knows
# outputs: True 
# Is URIRef `mary_uri` in john.foaf_knows?
print URIRef(mary_uri) in john.foaf_knows
# outputs: True 

The new bit is last few lines of the example–list membership testing. So a fairly small thing, but it didn’t work correctly before and it’s these small things that build up the overall experience. Being more pythonic, having better integration with Python idioms is one of the areas where SuRF can improve a lot. For example there’s also the issue about transparently mapping Literals to Python built-in datatypes on the waiting list.