本文整理匯總了Python中rhodecode.model.db.RhodeCodeSetting.get_default_repo_settings方法的典型用法代碼示例。如果您正苦於以下問題:Python RhodeCodeSetting.get_default_repo_settings方法的具體用法?Python RhodeCodeSetting.get_default_repo_settings怎麽用?Python RhodeCodeSetting.get_default_repo_settings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rhodecode.model.db.RhodeCodeSetting
的用法示例。
在下文中一共展示了RhodeCodeSetting.get_default_repo_settings方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_update
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def test_update(self):
self.log_user()
params = {
'default_repo_enable_locking': True,
'default_repo_enable_downloads': True,
'default_repo_enable_statistics': True,
'default_repo_private': True,
'default_repo_type': 'hg',
}
response = self.app.put(url('default', id='default'), params=params)
self.checkSessionFlash(response, 'Default settings updated successfully')
defs = RhodeCodeSetting.get_default_repo_settings()
self.assertEqual(params, defs)
params = {
'default_repo_enable_locking': False,
'default_repo_enable_downloads': False,
'default_repo_enable_statistics': False,
'default_repo_private': False,
'default_repo_type': 'git',
}
response = self.app.put(url('default', id='default'), params=params)
self.checkSessionFlash(response, 'Default settings updated successfully')
defs = RhodeCodeSetting.get_default_repo_settings()
self.assertEqual(params, defs)
示例2: create_repository
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def create_repository(self):
"""GET /_admin/create_repository: Form to create a new item"""
new_repo = request.GET.get('repo', '')
parent_group = request.GET.get('parent_group')
if not HasPermissionAny('hg.admin', 'hg.create.repository')():
#you're not super admin nor have global create permissions,
#but maybe you have at least write permission to a parent group ?
_gr = RepoGroup.get(parent_group)
gr_name = _gr.group_name if _gr else None
if not HasReposGroupPermissionAny('group.admin', 'group.write')(group_name=gr_name):
raise HTTPForbidden
acl_groups = GroupList(RepoGroup.query().all(),
perm_set=['group.write', 'group.admin'])
c.repo_groups = RepoGroup.groups_choices(groups=acl_groups)
c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
choices, c.landing_revs = ScmModel().get_repo_landing_revs()
c.new_repo = repo_name_slug(new_repo)
## apply the defaults from defaults page
defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
if parent_group:
defaults.update({'repo_group': parent_group})
return htmlfill.render(
render('admin/repos/repo_add.html'),
defaults=defaults,
errors={},
prefix_error=False,
encoding="UTF-8"
)
示例3: create
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def create(self, form_data, cur_user, just_db=False, fork=None):
"""
Backward compatibility function, just a wrapper on top of create_repo
:param form_data:
:param cur_user:
:param just_db:
:param fork:
"""
owner = cur_user
repo_name = form_data['repo_name_full']
repo_type = form_data['repo_type']
description = form_data['repo_description']
private = form_data['repo_private']
clone_uri = form_data.get('clone_uri')
repos_group = form_data['repo_group']
landing_rev = form_data['repo_landing_rev']
copy_fork_permissions = form_data.get('copy_permissions')
fork_of = form_data.get('fork_parent_id')
## repo creation defaults, private and repo_type are filled in form
defs = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
enable_statistics = defs.get('repo_enable_statistics')
enable_locking = defs.get('repo_enable_locking')
enable_downloads = defs.get('repo_enable_downloads')
return self.create_repo(
repo_name, repo_type, description, owner, private, clone_uri,
repos_group, landing_rev, just_db, fork_of, copy_fork_permissions,
enable_statistics, enable_locking, enable_downloads
)
示例4: index
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def index(self, format='html'):
"""GET /defaults: All items in the collection"""
# url('defaults')
c.backends = BACKENDS.keys()
defaults = RhodeCodeSetting.get_default_repo_settings()
return htmlfill.render(
render('admin/defaults/defaults.html'),
defaults=defaults,
encoding="UTF-8",
force_defaults=False
)
示例5: new
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def new(self, format='html'):
"""GET /repos/new: Form to create a new item"""
new_repo = request.GET.get('repo', '')
c.new_repo = repo_name_slug(new_repo)
self.__load_defaults()
## apply the defaults from defaults page
defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
return htmlfill.render(
render('admin/repos/repo_add.html'),
defaults=defaults,
errors={},
prefix_error=False,
encoding="UTF-8"
)
示例6: create_repository
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def create_repository(self):
"""GET /_admin/create_repository: Form to create a new item"""
c.repo_groups = RepoGroup.groups_choices(check_perms=True)
c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
choices, c.landing_revs = ScmModel().get_repo_landing_revs()
new_repo = request.GET.get('repo', '')
c.new_repo = repo_name_slug(new_repo)
## apply the defaults from defaults page
defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
return htmlfill.render(
render('admin/repos/repo_add_create_repository.html'),
defaults=defaults,
errors={},
prefix_error=False,
encoding="UTF-8"
)
示例7: repo2db_mapper
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def repo2db_mapper(initial_repo_list, remove_obsolete=False,
install_git_hook=False):
"""
maps all repos given in initial_repo_list, non existing repositories
are created, if remove_obsolete is True it also check for db entries
that are not in initial_repo_list and removes them.
:param initial_repo_list: list of repositories found by scanning methods
:param remove_obsolete: check for obsolete entries in database
:param install_git_hook: if this is True, also check and install githook
for a repo if missing
"""
from rhodecode.model.repo import RepoModel
from rhodecode.model.scm import ScmModel
sa = meta.Session()
rm = RepoModel()
user = sa.query(User).filter(User.admin == True).first()
if user is None:
raise Exception('Missing administrative account!')
added = []
##creation defaults
defs = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
enable_statistics = defs.get('repo_enable_statistics')
enable_locking = defs.get('repo_enable_locking')
enable_downloads = defs.get('repo_enable_downloads')
private = defs.get('repo_private')
for name, repo in initial_repo_list.items():
group = map_groups(name)
db_repo = rm.get_by_repo_name(name)
# found repo that is on filesystem not in RhodeCode database
if not db_repo:
log.info('repository %s not found, creating now' % name)
added.append(name)
desc = (repo.description
if repo.description != 'unknown'
else '%s repository' % name)
new_repo = rm.create_repo(
repo_name=name,
repo_type=repo.alias,
description=desc,
repos_group=getattr(group, 'group_id', None),
owner=user,
just_db=True,
enable_locking=enable_locking,
enable_downloads=enable_downloads,
enable_statistics=enable_statistics,
private=private
)
# we added that repo just now, and make sure it has githook
# installed
if new_repo.repo_type == 'git':
ScmModel().install_git_hook(new_repo.scm_instance)
new_repo.update_changeset_cache()
elif install_git_hook:
if db_repo.repo_type == 'git':
ScmModel().install_git_hook(db_repo.scm_instance)
# during starting install all cache keys for all repositories in the
# system, this will register all repos and multiple instances
cache_key = CacheInvalidation._get_cache_key(name)
log.debug("Creating invalidation cache key for %s: %s", name, cache_key)
CacheInvalidation.invalidate(name)
sa.commit()
removed = []
if remove_obsolete:
# remove from database those repositories that are not in the filesystem
for repo in sa.query(Repository).all():
if repo.repo_name not in initial_repo_list.keys():
log.debug("Removing non-existing repository found in db `%s`" %
repo.repo_name)
try:
sa.delete(repo)
sa.commit()
removed.append(repo.repo_name)
except Exception:
#don't hold further removals on error
log.error(traceback.format_exc())
sa.rollback()
return added, removed
示例8: create_repo
# 需要導入模塊: from rhodecode.model.db import RhodeCodeSetting [as 別名]
# 或者: from rhodecode.model.db.RhodeCodeSetting import get_default_repo_settings [as 別名]
def create_repo(self, apiuser, repo_name, owner=Optional(OAttr('apiuser')),
repo_type=Optional('hg'),
description=Optional(''), private=Optional(False),
clone_uri=Optional(None), landing_rev=Optional('tip'),
enable_statistics=Optional(False),
enable_locking=Optional(False),
enable_downloads=Optional(False)):
"""
Create repository, if clone_url is given it makes a remote clone
if repo_name is within a group name the groups will be created
automatically if they aren't present
:param apiuser:
:param repo_name:
:param onwer:
:param repo_type:
:param description:
:param private:
:param clone_uri:
:param landing_rev:
"""
if HasPermissionAnyApi('hg.admin')(user=apiuser) is False:
if not isinstance(owner, Optional):
#forbid setting owner for non-admins
raise JSONRPCError(
'Only RhodeCode admin can specify `owner` param'
)
if isinstance(owner, Optional):
owner = apiuser.user_id
owner = get_user_or_error(owner)
if RepoModel().get_by_repo_name(repo_name):
raise JSONRPCError("repo `%s` already exist" % repo_name)
defs = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
if isinstance(private, Optional):
private = defs.get('repo_private') or Optional.extract(private)
if isinstance(repo_type, Optional):
repo_type = defs.get('repo_type')
if isinstance(enable_statistics, Optional):
enable_statistics = defs.get('repo_enable_statistics')
if isinstance(enable_locking, Optional):
enable_locking = defs.get('repo_enable_locking')
if isinstance(enable_downloads, Optional):
enable_downloads = defs.get('repo_enable_downloads')
clone_uri = Optional.extract(clone_uri)
description = Optional.extract(description)
landing_rev = Optional.extract(landing_rev)
try:
# create structure of groups and return the last group
group = map_groups(repo_name)
repo = RepoModel().create_repo(
repo_name=repo_name,
repo_type=repo_type,
description=description,
owner=owner,
private=private,
clone_uri=clone_uri,
repos_group=group,
landing_rev=landing_rev,
enable_statistics=enable_statistics,
enable_downloads=enable_downloads,
enable_locking=enable_locking
)
Session().commit()
return dict(
msg="Created new repository `%s`" % (repo.repo_name),
repo=repo.get_api_data()
)
except Exception:
log.error(traceback.format_exc())
raise JSONRPCError('failed to create repository `%s`' % repo_name)