Example #1
0
class Symptom(Object):

    diseases = tag_collection(u'test/diseases', map_type=Disease)

    def __repr__(self):
        return '<Symptom: %s>' % self.about


# XXX well this is going to have to improve!
Disease.__dict__['symptoms'].map_type = Symptom


if __name__ == '__main__':
    from fom.dev import sandbox_fluid
    sandbox_fluid()
    chest_pain = Symptom(about='symptom:Chest Pain')
    heartburn = Symptom(about='symptom:Heartburn')
    dizziness = Symptom(about='symptom:Dizziness')
    ischaemic_heart_disease = Disease(about='disease:Ischaemic Hear Disease')
    ischaemic_heart_disease.symptoms.add(chest_pain)
    ischaemic_heart_disease.symptoms.add(dizziness)
    gastric_ulcer = Disease(about='disease:Gastric Ulcer')
    gastric_ulcer.symptoms.add(chest_pain)
    gastric_ulcer.symptoms.add(heartburn)
    print 'Ischaemic Heart Disease', ischaemic_heart_disease.symptoms
    print 'Gastric Ulcer', gastric_ulcer.symptoms
    print 'Chest Pain', chest_pain.diseases
    print 'Heartburn', heartburn.diseases
    print 'Dizziness', dizziness.diseases
Example #2
0

from fom.dev import sandbox_fluid
from fom.mapping import Object, Namespace, tag_value, tag_relation

# Use and bind the sandbox (for playing)
fluid = sandbox_fluid()

# let's start by creating a new Namespace for this application and then some
# tags

# Use the test user's namespace
ns = Namespace(u'test')

# create a child namespace for ourselves
ns.create_namespace(u'maptest', u'a test namespace')

# use our child namespace
ns = Namespace(u'test/maptest')

# create some tags
ns.create_tag(u'description', u'description', indexed=False)
ns.create_tag(u'timestamp', u'description', indexed=False)
ns.create_tag(u'username', u'description', indexed=False)


# Now we will define some behaviours mapping to groups of individual tags

class Describable(Object):
    """Mixin to provide describable behaviour
    """
Example #3
0
from fom.dev import sandbox_fluid
from fom.mapping import Object, Namespace, tag_value, tag_relation

# Use and bind the sandbox (for playing)
fluid = sandbox_fluid()

# let's start by creating a new Namespace for this application and then some
# tags

# Use the test user's namespace
ns = Namespace(u'test')

# create a child namespace for ourselves
ns.create_namespace(u'maptest', u'a test namespace')

# use our child namespace
ns = Namespace(u'test/maptest')

# create some tags
ns.create_tag(u'description', u'description', indexed=False)
ns.create_tag(u'timestamp', u'description', indexed=False)
ns.create_tag(u'username', u'description', indexed=False)

# Now we will define some behaviours mapping to groups of individual tags


class Describable(Object):
    """Mixin to provide describable behaviour
    """
    description = tag_value(u'test/maptest/description')