def lookup_all(context_path=None, parent_path=None, **kwargs): logger.debug("context_path: %s, parent_path: %s, kwargs: %s" % (context_path, parent_path, kwargs)) base_path = context_path or parent_path #XXX clean this up if not base_path or base_path == '/': if parent_path: # TODO implement lookup_all_parent ws doing lookup passing parent_path to search children first ws_url = settings.ZTREE_WS_BASE_URL + '/lookup_all_parent' else: ws_url = settings.ZTREE_WS_BASE_URL + '/lookup_all' else: if parent_path: # TODO implement lookup_all_parent ws doing lookup passing parent_path to search children first ws_url = settings.ZTREE_WS_BASE_URL + base_path + '/lookup_all_parent' else: ws_url = settings.ZTREE_WS_BASE_URL + base_path + '/lookup_all' #XXX TODO check if subsequent requests will always have the same query str # as kwargs does not guarantee order of keys (for caching) nodes_found = [] resp = dispatch_request_json(ws_url, data=kwargs) (content, meta) = _unpack_response(resp) if content: for n in deserialize_node(content, many=True): logger.debug("got node: %s" % n.absolute_path) nodes_found.append(n) return (nodes_found, meta)
def lookup(context_path=None, parent_path=None, **kwargs): logger.debug("context_path: %s, parent_path: %s, kwargs: %s" % (context_path, parent_path, kwargs)) base_path = context_path or parent_path #XXX clean this up if not base_path or base_path == '/': if parent_path: # TODO implement lookup_parent ws doing lookup passing parent_path to search children first ws_url = settings.ZTREE_WS_BASE_URL + '/lookup_parent' else: ws_url = settings.ZTREE_WS_BASE_URL + '/lookup' else: if parent_path: # TODO implement lookup_parent ws doing lookup passing parent_path to search children first ws_url = settings.ZTREE_WS_BASE_URL + base_path + '/lookup_parent' else: ws_url = settings.ZTREE_WS_BASE_URL + base_path + '/lookup' #XXX TODO check if subsequent requests will always have the same query str # as kwargs does not guarantee order of keys (for caching) resp = dispatch_request_json(ws_url, data=kwargs) if resp: node = deserialize_node(resp) logger.debug("got node: %s" % node.absolute_path) return (node, None) logger.warning("node not found") return (None, None)
def get_node(node_path, **kwargs): logger.info("node_path: %s, kwargs: %s" % (node_path, kwargs)) ws_url = settings.ZTREE_WS_BASE_URL + node_path resp = dispatch_request_json(ws_url, data=kwargs) if resp: node = deserialize_node(resp) if node: logger.debug("got node: %s" % node.absolute_path) return (node, None) logger.warning("node not found") return (None, None)
def __call__(self, request, create_content_type, **kwargs): content_type_name = create_content_type.app_label + '.' + create_content_type.model submit_data = {'ct': content_type_name, 'authenticated_username': request.user.username, #'slug': slug, } submit_data.update(kwargs) if request.tree_context.node: ws_create_content_uri = settings.ZTREE_WS_BASE_URL \ + request.tree_context.node.absolute_path + '/create' else: ws_create_content_uri = settings.ZTREE_WS_BASE_URL + '/create' resp = dispatch_request_json(ws_create_content_uri, method='POST', data=submit_data) return deserialize_node(resp)
def filter_descendants(parent_path, **kwargs): logger.info("parent_path: %s, kwargs: %s" % (parent_path, kwargs)) if not parent_path or parent_path == '/': ws_url = settings.ZTREE_WS_BASE_URL + '/search' else: ws_url = settings.ZTREE_WS_BASE_URL + parent_path + '/search' #XXX TODO check if subsequent requests will always have the same query str # as kwargs does not guarantee order of keys (for caching) nodes_found = [] resp = dispatch_request_json(ws_url, data=kwargs) (content, meta) = _unpack_response(resp) if content: for n in deserialize_node(content, many=True): logger.debug("got node: %s" % n.absolute_path) nodes_found.append(n) return (nodes_found, meta)
def __call__(self, request, content_object, **kwargs): submit_data = {'authenticated_username': request.user.username} submit_data.update(kwargs) ws_update_content_uri = settings.ZTREE_WS_BASE_URL + request.tree_context.node.absolute_path + '/update' resp = dispatch_request_json(ws_update_content_uri, method='POST', data=submit_data) return deserialize_node(resp)