Example #1
0
def modifyproperty(user_id, object_id, property_id, name, value, type, owner):
    with tasks.get_exchange(user_id) as x:
        p = x.load('property', property_id)
        p.set_name(name)
        p.set_owner(x.get_object(owner))
        p.set_value(json.loads(value, exchange=x), type=type)
    
    return {'response': True}
Example #2
0
def modifyproperty(user_id, object_id, property_id, name, value, type, owner):
    with tasks.get_exchange(user_id) as x:
        p = x.load('property', property_id)
        p.set_name(name)
        p.set_owner(x.get_object(owner))
        p.set_value(json.loads(value, exchange=x), type=type)

    return {'response': True}
Example #3
0
def modifyaccess(user_id, object_id, type, access):
    with tasks.get_exchange(user_id) as x:
        subject = x.get_object(object_id)
        for rule in access:
            if (rule['access'] == 'accessor'):
                rule['accessor'] = x.get_object(rule['accessor'])
            x.update_access(subject=subject, **rule)

    return {'response': True}
Example #4
0
def modifyaccess(user_id, object_id, type, access):
    with tasks.get_exchange(user_id) as x:
        subject = x.get_object(object_id)
        for rule in access:
            if(rule['access'] == 'accessor'):
                rule['accessor'] = x.get_object(rule['accessor'])
            x.update_access(subject=subject, **rule)

    return {'response': True}
Example #5
0
def modifyverb(user_id, object_id, verb_id, names, code, ability, method, owner):
    with tasks.get_exchange(user_id) as x:
        names = [n.strip() for n in names.split(',')]
        
        v = x.load('verb', verb_id)
        v.set_names(names)
        v.set_owner(x.get_object(owner))
        v.set_code(code)
        
        v.set_ability(ability)
        v.set_method(method)
    
    return {'response': True}
Example #6
0
def modifyverb(user_id, object_id, verb_id, names, code, ability, method,
               owner):
    with tasks.get_exchange(user_id) as x:
        names = [n.strip() for n in names.split(',')]

        v = x.load('verb', verb_id)
        v.set_names(names)
        v.set_owner(x.get_object(owner))
        v.set_code(code)

        v.set_ability(ability)
        v.set_method(method)

    return {'response': True}
Example #7
0
def modifyobject(user_id, object, name, location, parents, owner):
    with tasks.get_exchange(user_id) as x:
        o = x.get_object(object)
        o.set_name(name, real=True)
        o.set_location(x.get_object(location) if location else None)
        o.set_owner(x.get_object(owner))

        old_parents = o.get_parents()
        new_parents = [x.get_object(p) for p in parents]

        [o.remove_parent(p) for p in old_parents if p not in new_parents]
        [o.add_parent(p) for p in new_parents if p not in old_parents]

    return {'response': True}
Example #8
0
def openaccess(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        origin = x.get_object(object_id)
        caller = x.get_object(user_id)
        if (type == 'object'):
            item = origin
        else:
            item = getattr(origin, 'get_' + type)(name)

        p = parser.TransactionParser(parser.Lexer(''), caller, x)
        from antioch.plugins import editors
        editors.access(p, item)

    return {'response': True}
Example #9
0
def openeditor(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        if(type == 'object'):
            item = x.get_object(object_id)
        else:
            item = getattr(x, 'get_' + type)(object_id, name)
            if(item is None):
                item = x.instantiate(type, owner_id=user_id, origin_id=object_id, name=name)
        caller = x.get_object(user_id)
        p = parser.TransactionParser(parser.Lexer(''), caller, x)
        from antioch.plugins import editors
        editors.edit(p, item)
    
    return {'response': True}
Example #10
0
def openaccess(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        origin = x.get_object(object_id)
        caller = x.get_object(user_id)
        if(type == 'object'):
            item = origin
        else:
            item = getattr(origin, 'get_' + type)(name)
        
        p = parser.TransactionParser(parser.Lexer(''), caller, x)
        from antioch.plugins import editors
        editors.access(p, item)
    
    return {'response': True}
Example #11
0
def modifyobject(user_id, object, name, location, parents, owner):
    with tasks.get_exchange(user_id) as x:
        o = x.get_object(object)
        o.set_name(name, real=True)
        o.set_location(x.get_object(location) if location else None)
        o.set_owner(x.get_object(owner))
        
        old_parents = o.get_parents()
        new_parents = [x.get_object(p) for p in parents]
        
        [o.remove_parent(p) for p in old_parents if p not in new_parents]
        [o.add_parent(p) for p in new_parents if p not in old_parents]
    
    return {'response': True}
Example #12
0
def openeditor(user_id, object_id, type, name):
    with tasks.get_exchange(user_id) as x:
        if (type == 'object'):
            item = x.get_object(object_id)
        else:
            item = getattr(x, 'get_' + type)(object_id, name)
            if (item is None):
                item = x.instantiate(type,
                                     owner_id=user_id,
                                     origin_id=object_id,
                                     name=name)
        caller = x.get_object(user_id)
        p = parser.TransactionParser(parser.Lexer(''), caller, x)
        from antioch.plugins import editors
        editors.edit(p, item)

    return {'response': True}
Example #13
0
def enableplayer(player_id):
    with tasks.get_exchange() as x:
        code.run_system_verb(x, 'enable_player', x.get_object(x.get_avatar_id(player_id)))
    
    return dict(result=True)
Example #14
0
def addplayer(name, passwd, enabled=True):
    log.debug("Creating a player for %r" % name)
    with tasks.get_exchange() as x:
        user = code.run_system_verb(x, 'add_player', name=name, passwd=passwd, enabled=enabled)

    return user.id
Example #15
0
def removeproperty(user_id, object_id, property_name):
    with tasks.get_exchange(user_id) as x:
        obj = x.get_object(object_id)
        obj.remove_property(property_name)

    return {'response': True}
Example #16
0
def removeverb(user_id, object_id, verb_name):
    with tasks.get_exchange(user_id) as x:
        obj = x.get_object(object_id)
        obj.remove_verb(verb_name)

    return {'response': True}
Example #17
0
def getobjectdetails(user_id, object_id):
    with tasks.get_exchange(user_id) as x:
        obj = x.get_object(object_id)
        details = obj.get_details()
    
    return details
Example #18
0
def addplayer(name, passwd, enabled=True):
    log.debug("Creating a player for %r" % name)
    with tasks.get_exchange() as x:
        user = code.run_system_verb(x, 'add_player', name=name, passwd=passwd, enabled=enabled)

    return user.id
Example #19
0
def removeproperty(user_id, object_id, property_name):
    with tasks.get_exchange(user_id) as x:
        obj = x.get_object(object_id)
        obj.remove_property(property_name)
    
    return {'response': True}
Example #20
0
def removeverb(user_id, object_id, verb_name):
    with tasks.get_exchange(user_id) as x:
        obj = x.get_object(object_id)
        obj.remove_verb(verb_name)
    
    return {'response': True}
Example #21
0
def enableplayer(player_id):
    with tasks.get_exchange() as x:
        code.run_system_verb(x, 'enable_player', x.get_object(x.get_avatar_id(player_id)))
    
    return dict(result=True)
Example #22
0
def getobjectdetails(user_id, object_id):
    with tasks.get_exchange(user_id) as x:
        obj = x.get_object(object_id)
        details = obj.get_details()

    return details