コード例 #1
0
ファイル: memcached.py プロジェクト: xulong2005/zato
def instance_hook(self, input, instance, attrs):
    common_instance_hook(self, input, instance, attrs)

    if attrs.is_create_edit:
        # Parse extra arguments to confirm their syntax is correct
        parse_extra_into_dict(input.extra)

    elif attrs.is_delete:
        if instance.is_default:
            raise BadRequest(self.cid, 'Cannot delete the default cache')
        else:
            input.cache_type = instance.cache_type
コード例 #2
0
def instance_hook(self, input, instance, attrs):

    # Common functionality first ..
    common_instance_hook(self, input, instance, attrs)

    # .. now, if this is an update, we need to ensure that we have
    # a handle to cache_id. It will be provided on input from web-admin
    # but enmasse will not have it so we need to look it up ourselfves.
    if not input.get('cache_id'):
        if attrs.is_edit:
            with attrs._meta_session.no_autoflush:
                result = attrs._meta_session.query(CacheBuiltin.cache_id).\
                    filter(CacheBuiltin.id==input.id).\
                    filter(CacheBuiltin.cluster_id==self.server.cluster_id).\
                    one()

            instance.cache_id = result.cache_id