예제 #1
0
# Public attributes
for pubkey in ['creator', 'description', 'keywords', 'timestart', 'timeend', 'location', 'www']:
    comattrs[pubkey] = publicstring()

comattrs['creatoruid'] = Meta_Attribute(str, public=True, is_valid=lambda n, v: valid_uid(v))

comattrs['iconversion'] = Meta_Attribute(int, public=True, is_valid=is_unsigned_int, default=0)

comattrs['name'] = Meta_Attribute(str, public=True, is_valid=lambda n, v: valid_community(v))
comattrs['name'].is_required()

# Private attributes
comattrs['cid'] = privateunsignedint()
comattrs['invisible'] = privatebool(default=False)
comattrs['members'] = Meta_Attribute(list, public=False, is_valid=lambda n, v: validate_list(v, valid_uid), default=[])
comattrs['keys'] = privatestringlist()
comattrs['peer'] = Meta_Attribute(bool, public=False, default=True)
comattrs['public'] = Meta_Attribute(bool, public=False, default=True)
comattrs['iconlocked'] = Meta_Attribute(bool, public=False, default=False)
comattrs['myiconversion'] = privateunsignedint()

# Private non-saved
# Nothing atm

class Community(Meta):
    """ There are two very important properties in a community.
    Community is a 'peer community' iff peer attribute is true. This
    means anyone may belong to the community by simply stating it.
    If peer is false, the user decides who belongs to it. In this case,
    it is called a 'personal community'.
예제 #2
0
파일: user.py 프로젝트: proximate/proximate
# of User shares the same metaattributes dictionary.
userattributes = {}

# Public attributes
for pubkey in ['age', 'birth_date', 'city', 'country', 'description', 'email', 'gender', 'languages', 'name', 'occupation', 'phone_numbers', 'state', 'status', 'www']:
    userattributes[pubkey] = publicstring()

def community_filter(user, value):
    communities = []
    tempcommunities = user.get('tempcommunities')
    for name in value:
        if name not in tempcommunities:
            communities.append(name)
    return communities

userattributes['communities'] = Meta_Attribute(list, public=True, is_valid=lambda n, v: validate_list(v, valid_community), default=[DEFAULT_COMMUNITY_NAME])
userattributes['communities'].is_required()
userattributes['communities'].process_before_save(community_filter)

userattributes['faceversion'] = Meta_Attribute(int, public=True, is_valid=is_unsigned_int, default=0)
userattributes['fscounter'] = Meta_Attribute(int, public=True, is_valid=is_unsigned_int, default=0)
userattributes['fscounter'].is_required()

userattributes['nick'] = Meta_Attribute(str, public=True, is_valid=lambda n, v: valid_nick(v), default=TP_NICK_DEFAULT)
userattributes['nick'].is_required()
userattributes['status_icon'] = Meta_Attribute(str, public=True, is_valid=lambda n, v: valid_status(v))
userattributes['uid'] = Meta_Attribute(str, public=True, is_valid=lambda n, v: valid_uid(v))
userattributes['uid'].is_required()

# Private attributes
userattributes['key_fname'] = privatestring()