The models
module¶
kallithea.model¶
The application’s model objects
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Nov 25, 2010 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
example: | from paste.deploy import appconfig
from pylons import config
from sqlalchemy import engine_from_config
from kallithea.config.environment import load_environment
conf = appconfig('config:development.ini', relative_to = './../../')
load_environment(conf.global_conf, conf.local_conf)
engine = engine_from_config(config, 'sqlalchemy.')
init_model(engine)
# RUN YOUR CODE HERE
|
---|
kallithea.model.comment¶
comments model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Nov 11, 2011 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
class
kallithea.model.comment.
ChangesetCommentsModel
(sa=None)[source]¶ -
cls
¶ alias of
kallithea.model.db.ChangesetComment
-
create
(text, repo, user, revision=None, pull_request=None, f_path=None, line_no=None, status_change=None, closing_pr=False, send_email=True)[source]¶ Creates a new comment for either a changeset or a pull request. status_change and closing_pr is only for the optional email.
Returns the created comment.
-
kallithea.model.notification¶
Model for notifications
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Nov 20, 2011 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
class
kallithea.model.notification.
NotificationModel
(sa=None)[source]¶ -
cls
¶ alias of
kallithea.model.db.Notification
-
create
(created_by, subject, body, recipients=None, type_=u'message', with_email=True, email_kwargs={})[source]¶ Creates notification of given type
Parameters: - created_by – int, str or User instance. User who created this notification
- subject –
- body –
- recipients – list of int, str or User objects, when None is given send to all admins
- type – type of notification
- with_email – send email with this notification
- email_kwargs – additional dict to pass as args to email template
-
kallithea.model.permission¶
permissions model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Aug 20, 2010 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
class
kallithea.model.permission.
PermissionModel
(sa=None)[source]¶ Permissions model for Kallithea
-
cls
¶ alias of
kallithea.model.db.Permission
-
kallithea.model.repo_permission¶
repository permission model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Oct 1, 2011 :author: nvinot, marcink
kallithea.model.repo¶
Repository model for kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Jun 5, 2010 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
class
kallithea.model.repo.
RepoModel
(sa=None)[source]¶ -
cls
¶ alias of
kallithea.model.db.Repository
-
create
(form_data, cur_user)[source]¶ Create repository using celery tasks
Parameters: - form_data –
- cur_user –
-
create_fork
(form_data, cur_user)[source]¶ Simple wrapper into executing celery task for fork creation
Parameters: - form_data –
- cur_user –
-
delete
(repo, forks=None, fs_remove=True, cur_user=None)[source]¶ Delete given repository, forks parameter defines what do do with attached forks. Throws AttachedForksError if deleted repo has attached forks
Parameters: - repo –
- forks – str ‘delete’ or ‘detach’
- fs_remove – remove(archive) repo from filesystem
-
get_all_user_repos
(user)[source]¶ Gets all repositories that user have at least read access
Parameters: user –
-
grant_user_group_permission
(repo, group_name, perm)[source]¶ Grant permission for user group on given repository, or update existing one if found
Parameters: - repo – Instance of Repository, repository_id, or repository name
- group_name – Instance of UserGroup, users_group_id, or user group name
- perm – Instance of Permission, or permission_name
-
grant_user_permission
(repo, user, perm)[source]¶ Grant permission for user on given repository, or update existing one if found
Parameters: - repo – Instance of Repository, repository_id, or repository name
- user – Instance of User, user_id or username
- perm – Instance of Permission, or permission_name
-
kallithea.model.repo_group¶
repo group model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Jan 25, 2011 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
class
kallithea.model.repo_group.
RepoGroupModel
(sa=None)[source]¶ -
cls
¶ alias of
kallithea.model.db.RepoGroup
-
delete_permission
(repo_group, obj, obj_type, recursive)[source]¶ Revokes permission for repo_group for given obj(user or users_group), obj_type can be user or user group
Parameters: - repo_group –
- obj – user or user group id
- obj_type – user or user group type
- recursive – recurse to all children of group
-
grant_user_group_permission
(repo_group, group_name, perm)[source]¶ Grant permission for user group on given repository group, or update existing one if found
Parameters: - repo_group – Instance of RepoGroup, repositories_group_id, or repositories_group name
- group_name – Instance of UserGroup, users_group_id, or user group name
- perm – Instance of Permission, or permission_name
-
grant_user_permission
(repo_group, user, perm)[source]¶ Grant permission for user on given repository group, or update existing one if found
Parameters: - repo_group – Instance of RepoGroup, repositories_group_id, or repositories_group name
- user – Instance of User, user_id or username
- perm – Instance of Permission, or permission_name
-
kallithea.model.scm¶
Scm model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Apr 9, 2010 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
kallithea.model.scm.
AvailableRepoGroupChoices
(top_perms, repo_group_perms, extras=())[source]¶ Return group_id,string tuples with choices for all the repo groups where the user has the necessary permissions.
Top level is -1.
-
class
kallithea.model.scm.
CachedRepoList
(db_repo_list, repos_path, order_by=None, perm_set=None)[source]¶ Cached repo list. Uses super-fast in-memory cache after initialization.
-
class
kallithea.model.scm.
ScmModel
(sa=None)[source]¶ Generic Scm Model
-
commit_change
(repo, repo_name, cs, user, author, message, content, f_path)[source]¶ Commit a change to a single file
Parameters: repo – a db_repo.scm_instance
-
create_nodes
(user, repo, message, nodes, parent_cs=None, author=None, trigger_push_hook=True)[source]¶ Commits specified nodes to repo.
Parameters: - user – Kallithea User object or user_id, the committer
- repo – Kallithea Repository object
- message – commit message
- nodes – mapping {filename:{‘content’:content},…}
- parent_cs – parent changeset, can be empty than it’s initial commit
- author – author of commit, cna be different that committer only for git
- trigger_push_hook – trigger push hooks
Returns: new committed changeset
-
delete_nodes
(user, repo, message, nodes, parent_cs=None, author=None, trigger_push_hook=True)[source]¶ Deletes specified nodes from repo.
Parameters: - user – Kallithea User object or user_id, the committer
- repo – Kallithea Repository object
- message – commit message
- nodes – mapping {filename:{‘content’:content},…}
- parent_cs – parent changeset, can be empty than it’s initial commit
- author – author of commit, cna be different that committer only for git
- trigger_push_hook – trigger push hooks
Returns: new committed changeset after deletion
-
get_nodes
(repo_name, revision, root_path='/', flat=True)[source]¶ Recursively walk root dir and return a set of all paths found.
Parameters: - repo_name – name of repository
- revision – revision for which to list nodes
- root_path – root path to list
- flat – return as a list, if False returns a dict with description
-
get_repo_landing_revs
(repo=None)[source]¶ Generates select option with tags branches and bookmarks (for hg only) grouped by type
Parameters: repo –
-
get_repos
(all_repos=None, sort_key=None, simple=False)[source]¶ Get all repos from db and for each repo create its backend instance and fill that backed with information from database
Parameters: - all_repos – list of repository names as strings give specific repositories list, good for filtering
- sort_key – initial sorting of repos
- simple – use SimpleCachedList - one without the SCM info
-
install_git_hooks
(repo, force_create=False)[source]¶ Creates a kallithea hook inside a git repository
Parameters: - repo – Instance of VCS repo
- force_create – Create even if same name hook exists
-
mark_for_invalidation
(repo_name, delete=False)[source]¶ Mark caches of this repo invalid in the database.
Parameters: repo_name – the repo for which caches should be marked invalid
-
kallithea.model.user¶
users model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Apr 9, 2010 :author: marcink :copyright: (c) 2013 RhodeCode GmbH, and others. :license: GPLv3, see LICENSE.md for more details.
-
class
kallithea.model.user.
UserModel
(sa=None)[source]¶ -
-
cls
¶ alias of
kallithea.model.db.User
-
create_or_update
(username, password, email, firstname='', lastname='', active=True, admin=False, extern_type=None, extern_name=None, cur_user=None)[source]¶ Creates a new instance if not found, or updates current one
Parameters: - username –
- password –
- email –
- active –
- firstname –
- lastname –
- active –
- admin –
- extern_name –
- extern_type –
- cur_user –
-
delete_extra_email
(user, email_id)[source]¶ Removes email address from UserEmailMap
Parameters: - user –
- email_id –
-
get_reset_password_token
(user, timestamp, session_id)[source]¶ The token is a 40-digit hexstring, calculated as a HMAC-SHA1.
In a traditional HMAC scenario, an attacker is unable to know or influence the secret key, but can know or influence the message and token. This scenario is slightly different (in particular since the message sender is also the message recipient), but sufficiently similar to use an HMAC. Benefits compared to a plain SHA1 hash includes resistance against a length extension attack.
The HMAC key consists of the following values (known only to the server and authorized users):
- per-application secret (the app_instance_uuid setting), without which an attacker cannot counterfeit tokens
- hashed user password, invalidating the token upon password change
The HMAC message consists of the following values (potentially known to an attacker):
- session ID (the anti-CSRF token), requiring an attacker to have access to the browser session in which the token was created
- numeric user ID, limiting the token to a specific user (yet allowing users to be renamed)
- user email address
- time of token issue (a Unix timestamp, to enable token expiration)
The key and message values are separated by NUL characters, which are guaranteed not to occur in any of the values.
-
send_reset_password_email
(data)[source]¶ Sends email with a password reset token and link to the password reset confirmation page with all information (including the token) pre-filled. Also returns URL of that page, only without the token, allowing users to copy-paste or manually enter the token from the email.
-
kallithea.model.user_group¶
user group model for Kallithea
This file was forked by the Kallithea project in July 2014. Original author and date, and relevant copyright and licensing information is below: :created_on: Oct 1, 2011 :author: nvinot, marcink
-
class
kallithea.model.user_group.
UserGroupModel
(sa=None)[source]¶ -
cls
¶ alias of
kallithea.model.db.UserGroup
-
delete
(user_group, force=False)[source]¶ Deletes user group, unless force flag is used raises exception if there are members in that group, else deletes group and users
Parameters: - user_group –
- force –
-
grant_user_group_permission
(target_user_group, user_group, perm)[source]¶ Grant user group permission for given target_user_group
Parameters: - target_user_group –
- user_group –
- perm –
-
grant_user_permission
(user_group, user, perm)[source]¶ Grant permission for user on given user group, or update existing one if found
Parameters: - user_group – Instance of UserGroup, users_group_id, or users_group_name
- user – Instance of User, user_id or username
- perm – Instance of Permission, or permission_name
-