class SurrogatePerson(Record): name = Property(isa=Name) ssn = Property(isa=str, check=lambda x: re.match(r'\d{3}-\d{2}-\d{4}', x)) date_of_birth = DateProperty() description = UnicodeProperty() phone_number = StringProperty() primary_key = [ssn]
class Project(JsonRecord): id = IdProperty() project_id = IntProperty() primary_key = [project_id] name = UnicodeProperty() description = UnicodeProperty() org_description = UnicodeProperty() purpose = UnicodeProperty() additional_info = UnicodeProperty() secondary_focus = StringProperty() state = StringProperty() project_type = IntProperty() focus = IntProperty() area = StringProperty() address = UnicodeProperty() contact_chapter = IdProperty(json_name="contact_chapter") first_funded = IntProperty() total_funds = FloatProperty() status = IntProperty() images = Property(isa=list)
class Event(JsonRecord): id = IdProperty() chapter = IdProperty() projects = Property(isa=list) name = UnicodeProperty() description = UnicodeProperty() location = UnicodeProperty() event_start = DateProperty() event_pricing = Property(isa=dict) rsvp_tickets = StringProperty() images = Property(isa=list)
class CompareThisOrz(SurrogatePerson): def full_number(self): number = normalize_phone(self.phone_number) m = re.match( r"(\d{3})\s*(?:[.-]\s*)?(\d{4})", number, ) if m: return "(%.3d) %s-%s" % ( self.area_code, m.group(1), m.group(2), ) else: return number area_code = IntProperty(check=lambda n: 0 < n < 1000) phone_number = StringProperty(compare_as=full_number)
class StarAttribute(Record): value = FloatProperty(required=True) unit = StringProperty()
class PersonEasilyComparable(SurrogatePerson): primary_key = ['ssn'] phone_number = StringProperty(compare_as=normalize_phone)
class Chapter(JsonRecord): id = IdProperty() chapter_id = IntProperty() name = UnicodeProperty() established_year = IntProperty() chapter_url = StringProperty()