Example #1
0
###
### The base class
###

class Movie(Model):
    """Simple model that has one StringType member
    """
    id = UUIDType(auto_fill=True)
    title = StringType(max_length=40)
    year = IntType(min_value=1950, max_value=datetime.datetime.now().year)
    personal_thoughts = StringType(max_length=255)

m = Movie(title='Some Movie',
          year=2011,
          personal_thoughts='It was pretty good')


### Serialize the schema and the data
m_schema = for_jsonschema(m)
m_data = to_python(m)
print 'M :: ', m_schema
print '\n'

### Rebuild class from schema
m2_cls = from_jsonschema(m_schema)

m2 = m2_cls()
print 'M2:: ', for_jsonschema(m2)
print '\n'
Example #2
0
 def for_jsonschema(self):
     return for_jsonschema(self.model_type)
Example #3
0
 def add_model(self, model):
     self.manifest[model.__name__.lower()] = for_jsonschema(model)
Example #4
0
 def _jsonschema_items(self):
     return [for_jsonschema(field) for field in self.fields]
Example #5
0
 def add_model(self, model):
     self.manifest[model.__name__.lower()] = for_jsonschema(model)
Example #6
0
 def for_jsonschema(self):
     return for_jsonschema(self.model_type)
Example #7
0
###
### The base class
###


class Movie(Model):
    """Simple model that has one StringType member
    """
    id = UUIDType(auto_fill=True)
    title = StringType(max_length=40)
    year = IntType(min_value=1950, max_value=datetime.datetime.now().year)
    personal_thoughts = StringType(max_length=255)


m = Movie(title='Some Movie',
          year=2011,
          personal_thoughts='It was pretty good')

### Serialize the schema and the data
m_schema = for_jsonschema(m)
m_data = to_python(m)
print 'M :: ', m_schema
print '\n'

### Rebuild class from schema
m2_cls = from_jsonschema(m_schema)

m2 = m2_cls()
print 'M2:: ', for_jsonschema(m2)
print '\n'