本文整理汇总了Python中seaserv.seafile_api.get_dir_id_by_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_dir_id_by_path函数的具体用法?Python get_dir_id_by_path怎么用?Python get_dir_id_by_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_dir_id_by_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: list_shared_links
def list_shared_links(request):
"""List shared links, and remove invalid links(file/dir is deleted or moved).
"""
username = request.user.username
# download links
fileshares = FileShare.objects.filter(username=username)
p_fileshares = [] # personal file share
for fs in fileshares:
if is_personal_repo(fs.repo_id): # only list files in personal repos
r = seafile_api.get_repo(fs.repo_id)
if not r:
fs.delete()
continue
if fs.s_type == 'f':
if seafile_api.get_file_id_by_path(r.id, fs.path) is None:
fs.delete()
continue
fs.filename = os.path.basename(fs.path)
fs.shared_link = gen_file_share_link(fs.token)
else:
if seafile_api.get_dir_id_by_path(r.id, fs.path) is None:
fs.delete()
continue
fs.filename = os.path.basename(fs.path.rstrip('/'))
fs.shared_link = gen_dir_share_link(fs.token)
fs.repo = r
p_fileshares.append(fs)
# upload links
uploadlinks = UploadLinkShare.objects.filter(username=username)
p_uploadlinks = []
for link in uploadlinks:
if is_personal_repo(link.repo_id):
r = seafile_api.get_repo(link.repo_id)
if not r:
link.delete()
continue
if seafile_api.get_dir_id_by_path(r.id, link.path) is None:
link.delete()
continue
link.dir_name = os.path.basename(link.path.rstrip('/'))
link.shared_link = gen_shared_upload_link(link.token)
link.repo = r
p_uploadlinks.append(link)
return render_to_response('share/links.html', {
"fileshares": p_fileshares,
"uploadlinks": p_uploadlinks,
}, context_instance=RequestContext(request))
开发者ID:datawerk,项目名称:seahub,代码行数:52,代码来源:views.py
示例2: delete
def delete(self, request, repo_id):
""" delete a single file/folder in a library
"""
path = request.GET.get('path', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
path = normalize_file_path(path)
file_id = None
dir_id = None
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not file_id and not dir_id:
return Response({'success': True})
parent_dir = os.path.dirname(path)
file_name = os.path.basename(path)
try:
seafile_api.del_file(repo_id,
parent_dir, file_name, request.user.username)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'success': True})
开发者ID:haiwen,项目名称:seahub,代码行数:35,代码来源:library_dirents.py
示例3: put
def put(self, request, repo_id):
""" Copy a single file/folder to other place.
"""
# check parameter for src
path = request.GET.get('path', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
dirent = seafile_api.get_dirent_by_path(repo_id, path)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not dirent:
error_msg = 'File or folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if path == '/':
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# normalize path to '/1/2/3' format
# NOT ends with '/'
path = normalize_file_path(path)
# now get `src_dir` and `obj_name` according to normalized path
src_repo_id = repo_id
src_dir = os.path.dirname(path)
src_obj_name = os.path.basename(path)
# check parameter for dst
dst_repo_id = request.data.get('dst_repo_id', src_repo_id)
if dst_repo_id != src_repo_id and not seafile_api.get_repo(dst_repo_id):
error_msg = 'Library %s not found.' % dst_repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
dst_dir = request.data.get('dst_dir', '/')
if dst_dir != '/':
dst_dir = normalize_dir_path(dst_dir)
if not seafile_api.get_dir_id_by_path(dst_repo_id, dst_dir):
error_msg = 'Folder %s not found.' % dst_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# copy file
username = request.user.username
dst_obj_name = check_filename_with_rename(dst_repo_id, dst_dir,
src_obj_name)
try:
seafile_api.copy_file(src_repo_id, src_dir, src_obj_name, dst_repo_id,
dst_dir, dst_obj_name, username, need_progress=0, synchronous=1)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'success': True, 'dst_item_name': dst_obj_name})
开发者ID:haiwen,项目名称:seahub,代码行数:60,代码来源:library_dirents.py
示例4: get
def get(self, request, repo_id, format=None):
""" Get all file/folder in a library
"""
repo = seafile_api.get_repo(repo_id)
parent_dir = request.GET.get('parent_dir', '/')
parent_dir = normalize_dir_path(parent_dir)
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
repo_owner = get_repo_owner(request, repo_id)
try:
dirs = seafile_api.list_dir_with_perm(repo_id,
parent_dir, dir_id, repo_owner, -1, -1)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return_results = {}
return_results['repo_name'] = repo.repo_name
return_results['repo_id'] = repo.repo_id
return_results['is_system_library'] = True if \
repo.id == get_system_default_repo_id() else False
return_results['dirent_list'] = []
for dirent in dirs:
dirent_info = get_dirent_info(dirent)
return_results['dirent_list'].append(dirent_info)
return Response(return_results)
开发者ID:haiwen,项目名称:seahub,代码行数:35,代码来源:library_dirents.py
示例5: get_locked_files_by_dir
def get_locked_files_by_dir(request, repo_id, folder_path):
""" Get locked files in a folder
Returns:
A dict contains locked file name and locker owner.
locked_files = {
'file_name': 'lock_owner';
...
}
"""
username = request.user.username
# get lock files
dir_id = seafile_api.get_dir_id_by_path(repo_id, folder_path)
dirents = seafile_api.list_dir_with_perm(repo_id,
folder_path, dir_id, username, -1, -1)
locked_files = {}
for dirent in dirents:
if dirent.is_locked:
locked_files[dirent.obj_name] = dirent.lock_owner
return locked_files
开发者ID:haiwen,项目名称:seahub,代码行数:25,代码来源:repo.py
示例6: check_group_folder_perm_args
def check_group_folder_perm_args(from_user, repo_id, path, group_id, perm = None):
if not seafile_api.get_repo(repo_id):
return {'error': _(u'Library does not exist.'), 'status': 400}
if check_repo_access_permission(repo_id, from_user) != 'rw':
return {'error': _('Permission denied'), 'status': 403}
if perm is not None:
# add or toggle folder perm
if seafile_api.get_dir_id_by_path(repo_id, path) is None:
return {'error': _('Invalid path'), 'status': 400}
if perm != 'r' and perm != 'rw':
return {'error': _('Invalid folder permission'), 'status': 400}
if not path.startswith('/'):
return {'error': _('Path should start with "/"'), 'status': 400}
if path != '/' and path.endswith('/'):
return {'error': _('Path should NOT ends with "/"'), 'status': 400}
if not seaserv.get_group(group_id):
return {'error': _('Invalid group'), 'status': 400}
return {'success': True}
开发者ID:biddyweb,项目名称:seahub,代码行数:25,代码来源:repo.py
示例7: _decorated
def _decorated(view, request, *args, **kwargs):
# argument check
if request.method == 'GET':
repo_id = request.GET.get('repo_id', None)
path = request.GET.get('path', '/')
share_type = request.GET.get('share_type', None)
else:
repo_id = request.data.get('repo_id', None)
path = request.data.get('path', '/')
share_type = request.data.get('share_type', None)
if not repo_id:
error_msg = 'repo_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not share_type or share_type not in ('user', 'group'):
error_msg = 'share_type invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
return func(view, request, repo, path, share_type, *args, **kwargs)
开发者ID:haiwen,项目名称:seahub,代码行数:31,代码来源:shares.py
示例8: get
def get(self, request, repo_id):
""" List repo user share info.
Permission checking:
1. is group admin
"""
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
repo_owner = get_repo_owner(request, repo_id)
group_id = get_group_id_by_repo_owner(repo_owner)
if not ccnet_api.get_group(group_id):
error_msg = 'Group %s not found.' % group_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = request.GET.get('path', '/')
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
username = request.user.username
if not is_group_admin(group_id, username):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
result = self.list_user_shared_items(request, repo_id, path)
return Response(result)
开发者ID:haiwen,项目名称:seahub,代码行数:32,代码来源:group_owned_libraries.py
示例9: get_dir_files_last_modified
def get_dir_files_last_modified(self, repo_id, parent_dir, dir_id=None):
"""Calc the last modified time of all the files under the directory
<parent_dir> of the repo <repo_id>. Return a dict whose keys are the
file names and values are their corresponding last modified timestamps.
Arguments:
- `self`:
- `repo_id`:
- `parent_dir`:
- `dir_id`:
"""
if not dir_id:
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
parent_dir_hash = calc_file_path_hash(parent_dir)
if not dir_id:
return {}
try:
info = super(DirFilesLastModifiedInfoManager, self).get(
repo_id=repo_id, parent_dir_hash=parent_dir_hash)
except self.model.DoesNotExist:
# no cache yet
return self._calc_dir_files_last_modified(repo_id, parent_dir,
parent_dir_hash, dir_id)
else:
# cache exist
if info.dir_id != dir_id:
# cache is outdated
info.delete()
return self._calc_dir_files_last_modified(repo_id, parent_dir,
parent_dir_hash, dir_id)
else:
# cache is valid
return json.loads(info.last_modified_info)
开发者ID:chu888chu888,项目名称:Seafile-seahub,代码行数:34,代码来源:models.py
示例10: check_user_folder_perm_args
def check_user_folder_perm_args(from_user, repo_id, path, to_user, perm=None):
if not seafile_api.get_repo(repo_id):
return {'error': _(u'Library does not exist.'), 'status': 400}
if check_repo_access_permission(repo_id, from_user) != 'rw':
return {'error': _('Permission denied'), 'status': 403}
if perm is not None:
# add or toggle folder perm
if seafile_api.get_dir_id_by_path(repo_id, path) is None:
return {'error': _('Invalid path'), 'status': 400}
if perm != 'r' and perm != 'rw':
return {'error': _('Invalid folder permission'), 'status': 400}
if not path.startswith('/'):
return {'error': _('Path should start with "/"'), 'status': 400}
if path != '/' and path.endswith('/'):
return {'error': _('Path should NOT ends with "/"'), 'status': 400}
try:
user = User.objects.get(email = to_user)
except User.DoesNotExist:
user = None
if user is None:
return {'error': _('Invalid username, should be a user already registered'), 'status': 400}
return {'success': True}
开发者ID:biddyweb,项目名称:seahub,代码行数:30,代码来源:repo.py
示例11: post
def post(self, request):
""" Create upload link.
Permission checking:
1. default(NOT guest) user;
2. user with 'rw' permission;
"""
# argument check
repo_id = request.data.get('repo_id', None)
if not repo_id:
error_msg = 'repo_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
path = request.data.get('path', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
password = request.data.get('password', None)
if password and len(password) < config.SHARE_LINK_PASSWORD_MIN_LENGTH:
error_msg = _('Password is too short')
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
try:
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not dir_id:
error_msg = 'folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if not self._can_generate_shared_link(request):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if check_folder_permission(request, repo_id, path) != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
username = request.user.username
uls = UploadLinkShare.objects.get_upload_link_by_path(username, repo_id, path)
if not uls:
uls = UploadLinkShare.objects.create_upload_link_share(username,
repo_id, path, password)
link_info = self._get_upload_link_info(uls)
return Response(link_info)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:58,代码来源:upload_links.py
示例12: put
def put(self, request, repo_id, org_id, format=None):
""" Update repo group share permission.
Permission checking:
1. is group admin
"""
# parameter check
to_group_id = request.data.get('group_id', None)
if not to_group_id:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
to_group_id = int(to_group_id)
except ValueError:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
permission = request.data.get('permission', PERMISSION_READ)
if permission not in [PERMISSION_READ, PERMISSION_READ_WRITE]:
error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
repo_owner = get_repo_owner(request, repo_id)
group_id = get_group_id_by_repo_owner(repo_owner)
if not ccnet_api.get_group(group_id):
error_msg = 'Group %s not found.' % group_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not ccnet_api.get_group(to_group_id):
error_msg = 'Group %s not found.' % to_group_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = request.data.get('path', '/')
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
username = request.user.username
if not is_group_admin(group_id, username):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
update_group_dir_permission(
repo_id, path, repo_owner, to_group_id, permission, org_id)
send_perm_audit_msg('modify-repo-perm',
username, to_group_id, repo_id, path, permission)
return Response({'success': True})
开发者ID:haiwen,项目名称:seahub,代码行数:58,代码来源:group_owned_libraries.py
示例13: get
def get(self, request):
""" List all starred file/folder.
Permission checking:
1. all authenticated user can perform this action.
"""
email = request.user.username
all_starred_items = UserStarredFiles.objects.filter(email=email)
repo_dict = {}
for starred_item in all_starred_items:
repo_id = starred_item.repo_id
if repo_id not in repo_dict:
repo = seafile_api.get_repo(repo_id)
if repo:
repo_dict[repo_id] = repo
starred_repos = []
starred_folders = []
starred_files = []
for starred_item in all_starred_items:
repo_id = starred_item.repo_id
if repo_id not in repo_dict:
continue
path = starred_item.path
if starred_item.is_dir:
if not seafile_api.get_dir_id_by_path(repo_id, path):
continue
else:
if not seafile_api.get_file_id_by_path(repo_id, path):
continue
repo = repo_dict[repo_id]
item_info = self.get_starred_item_info(repo, starred_item)
email = starred_item.email
item_info['user_email'] = email
item_info['user_name'] = email2nickname(email)
item_info['user_contact_email'] = email2contact_email(email)
if path == '/':
starred_repos.append(item_info)
elif starred_item.is_dir:
starred_folders.append(item_info)
else:
starred_files.append(item_info)
starred_repos.sort(lambda x, y: cmp(y['mtime'], x['mtime']))
starred_folders.sort(lambda x, y: cmp(y['mtime'], x['mtime']))
starred_files.sort(lambda x, y: cmp(y['mtime'], x['mtime']))
return Response({'starred_item_list': starred_repos + \
starred_folders + starred_files})
开发者ID:haiwen,项目名称:seahub,代码行数:56,代码来源:starred_items.py
示例14: repo_recycle_view
def repo_recycle_view(request, repo_id):
if not seafile_api.get_dir_id_by_path(repo_id, '/') or \
check_folder_permission(request, repo_id, '/') != 'rw':
return render_permission_error(request, _(u'Unable to view recycle page'))
commit_id = request.GET.get('commit_id', '')
if not commit_id:
return render_recycle_root(request, repo_id)
else:
return render_recycle_dir(request, repo_id, commit_id)
开发者ID:domal,项目名称:seahub,代码行数:10,代码来源:__init__.py
示例15: get
def get(self, request):
""" Get all upload links of a user.
Permission checking:
1. default(NOT guest) user;
"""
if not self._can_generate_shared_link(request):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# get all upload links
username = request.user.username
upload_link_shares = UploadLinkShare.objects.filter(username=username)
repo_id = request.GET.get('repo_id', None)
if repo_id:
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# filter share links by repo
upload_link_shares = filter(lambda ufs: ufs.repo_id==repo_id, upload_link_shares)
path = request.GET.get('path', None)
if path:
try:
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not dir_id:
error_msg = 'folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if path[-1] != '/':
path = path + '/'
# filter share links by path
upload_link_shares = filter(lambda ufs: ufs.path==path, upload_link_shares)
result = []
for uls in upload_link_shares:
link_info = self._get_upload_link_info(uls)
result.append(link_info)
if len(result) == 1:
result = result
else:
result.sort(lambda x, y: cmp(x['obj_name'], y['obj_name']))
return Response(result)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:55,代码来源:upload_links.py
示例16: _generate_obj_id_and_type_by_path
def _generate_obj_id_and_type_by_path(self, repo_id, path):
file_id = seafile_api.get_file_id_by_path(repo_id, path)
if file_id:
return (file_id, 'f')
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
if dir_id:
return (dir_id, 'd')
return (None, None)
开发者ID:TanLian,项目名称:seahub,代码行数:11,代码来源:share_links.py
示例17: get
def get(self, request, repo_id, format=None):
# list dir
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = request.GET.get('p', '/')
if path[-1] != '/':
path = path + '/'
try:
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not dir_id:
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if check_folder_permission(request, repo_id, path) is None:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
old_oid = request.GET.get('oid', None)
if old_oid and old_oid == dir_id:
resp = Response({'success': True})
resp["oid"] = dir_id
return resp
else:
request_type = request.GET.get('t', None)
if request_type and request_type not in ('f', 'd'):
error_msg = "'t'(type) should be 'f' or 'd'."
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if request_type == 'd':
recursive = request.GET.get('recursive', '0')
if recursive not in ('1', '0'):
error_msg = "If you want to get recursive dir entries, you should set 'recursive' argument as '1'."
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if recursive == '1':
username = request.user.username
dir_list = get_dir_recursively(username, repo_id, path, [])
dir_list.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower()))
resp = Response(dir_list)
resp["oid"] = dir_id
resp["dir_perm"] = seafile_api.check_permission_by_path(repo_id, path, username)
return resp
return get_dir_entrys_by_id(request, repo, path, dir_id, request_type)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:54,代码来源:dir.py
示例18: get
def get(self, request, repo_id, format=None):
""" get all file/folder in a library
"""
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not can_view_sys_admin_repo(repo):
error_msg = 'Feature disabled.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
parent_dir = request.GET.get('parent_dir', '/')
if not parent_dir:
error_msg = 'parent_dir invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if parent_dir[-1] != '/':
parent_dir = parent_dir + '/'
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
try:
dirs = seafserv_threaded_rpc.list_dir_with_perm(repo_id,
parent_dir, dir_id, repo_owner, -1, -1)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return_results = {}
return_results['repo_name'] = repo.repo_name
return_results['repo_id'] = repo.repo_id
return_results['is_system_library'] = True if \
repo.id == get_system_default_repo_id() else False
return_results['dirent_list'] = []
for dirent in dirs:
dirent_info = get_dirent_info(dirent)
return_results['dirent_list'].append(dirent_info)
return Response(return_results)
开发者ID:RaphaelWimmer,项目名称:seahub,代码行数:51,代码来源:library_dirents.py
示例19: get
def get(self, request):
""" get upload link.
"""
if not self._can_generate_shared_link(request):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
repo_id = request.GET.get('repo_id', None)
if repo_id:
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = request.GET.get('path', None)
if path:
try:
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not dir_id:
error_msg = 'folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
username = request.user.username
upload_link_shares = UploadLinkShare.objects.filter(username=username)
# filter result by args
if repo_id:
upload_link_shares = filter(lambda ufs: ufs.repo_id == repo_id, upload_link_shares)
if path:
if path[-1] != '/':
path = path + '/'
upload_link_shares = filter(lambda ufs: ufs.path == path, upload_link_shares)
result = []
for uls in upload_link_shares:
link_info = self._get_upload_link_info(uls)
result.append(link_info)
if len(result) == 1:
result = result[0]
return Response(result)
开发者ID:AviorAlong,项目名称:haiwen-5.1.3,代码行数:50,代码来源:upload_links.py
示例20: get
def get(self, request, repo_id):
""" Get dir info.
Permission checking:
1. user with either 'r' or 'rw' permission.
"""
# parameter check
path = request.GET.get('path', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
path = normalize_dir_path(path)
if path == '/':
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
if not dir_id:
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if not check_folder_permission(request, repo_id, path):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
dir_obj = seafile_api.get_dirent_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
dir_info = {
'repo_id': repo_id,
'path': path,
'name': dir_obj.obj_name,
'mtime': timestamp_to_isoformat_timestr(dir_obj.mtime),
}
return Response(dir_info)
开发者ID:haiwen,项目名称:seahub,代码行数:49,代码来源:dir.py
注:本文中的seaserv.seafile_api.get_dir_id_by_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论