# # This software is licensed under The Clear BSD license. # See the LICENSE file for more details. # from time import time from meta import Meta, Meta_Attribute, validate_list, privatebool, \ publicstring, publicunsignedint, privateunsignedint, privatestringlist, \ is_unsigned_int from proximateprotocol import valid_community, valid_uid 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)
# # All rights reserved. # # This software is licensed under The Clear BSD license. # See the LICENSE file for more details. # import os from meta import Meta, Meta_Attribute, publicstring from support import warning contentattributes = {} # Public attributes for pubkey in ['author', 'communities', 'description', 'communities', 'keywords', 'timestart', 'timeend', 'title', 'type', 'year']: contentattributes[pubkey] = publicstring() # Private non-saveable attributes contentattributes['fname'] = Meta_Attribute(str, public=False, save=False) class Content_Meta(Meta): metasection = 'meta' def __init__(self): self.metaattributes = contentattributes self.base_init() def meta_name(self, fname): dname = os.path.dirname(fname) bname = os.path.basename(fname) return os.path.join(dname, '.%s.proximatemeta' %(bname))
from meta import Meta, Meta_Attribute, validate_list, is_unsigned_int, \ publicstring, publicunsignedint, privatestring, privateunsignedint from proximateprotocol import valid_cid, valid_community, \ valid_nick, valid_status, TP_NICK_DEFAULT, \ valid_port, valid_protocol_version, valid_uid, \ DEFAULT_COMMUNITY_NAME, FRIENDS_COMMUNITY_NAME, \ MAX_USER_INACTIVITY_TIME, PROXIMATE_PROTOCOL_VERSION from utils import relative_time_string # Meta attributes are defined as class variables. That is, each instance # 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)