コード例 #1
0
ファイル: communitymeta.py プロジェクト: proximate/proximate
comattrs = {}

# 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.
コード例 #2
0
ファイル: user.py プロジェクト: proximate/proximate
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()
userattributes['privcommunities'] = Meta_Attribute(list, public=False, is_valid=lambda n, v: type(v) == list and validate_list(v, valid_cid), default=[])
userattributes['remotes'] = Meta_Attribute(list, public=False)
userattributes['friend'] = Meta_Attribute(bool, public=False, save=True, default=False)
userattributes['myfaceversion'] = privateunsignedint()

# Private non-saved attributes
userattributes['ip'] = Meta_Attribute(str, public=False, save=False, is_valid=lambda n, v: valid_ip(v))
userattributes['port'] = Meta_Attribute(int, public=False, save=False, is_valid=lambda n, v: valid_port(v))
userattributes['protocolversion'] = Meta_Attribute(int, public=False, save=False, is_valid=lambda n, v: valid_protocol_version(v), default=PROXIMATE_PROTOCOL_VERSION)

userattributes['tempcommunities'] = Meta_Attribute(list, public=False, save=False, is_valid=lambda n, v: validate_list(v, valid_community), default=[])

userattributes['timeout'] = Meta_Attribute(int, public=False, save=False, is_valid=is_unsigned_int)
userattributes['hops'] = Meta_Attribute(int, public=False, save=False, is_valid=is_unsigned_int)
userattributes['hophistory'] = Meta_Attribute(list, public=False, save=False)

class User(Meta):
    def __init__(self):
        self.metaattributes = userattributes