# -*- coding: utf-8 -*-
"""
rhodecode.controllers.admin.admin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Controller for Admin panel of Rhodecode
:created_on: Apr 7, 2010
:author: marcink
:copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
:license: GPLv3, see COPYING for more details.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 2
# of the License or (at your opinion) any later version of the license.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
from pylons import request, tmpl_context as c
from rhodecode.lib.base import BaseController, render
from rhodecode.model.db import UserLog
from webhelpers.paginate import Page
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
log = logging.getLogger(__name__)
class AdminController(BaseController):
rhodecode.controllers.admin.ldap_settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ldap controller for RhodeCode
:created_on: Nov 26, 2010
import formencode
import traceback
from formencode import htmlfill
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from pylons.i18n.translation import _
from rhodecode.lib import helpers as h
rhodecode.controllers.admin.permissions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
permissions controller for Rhodecode
:created_on: Apr 27, 2010
from pylons import request, session, tmpl_context as c, url
from rhodecode.lib.auth_ldap import LdapImportError
from rhodecode.model.forms import LdapSettingsForm, DefaultPermissionsForm
from rhodecode.model.permission import PermissionModel
from rhodecode.model.settings import SettingsModel
rhodecode.controllers.admin.repos
Admin controller for RhodeCode
:copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
from operator import itemgetter
from paste.httpexceptions import HTTPInternalServerError
rhodecode.controllers.admin.settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
settings controller for rhodecode admin
:created_on: Jul 14, 2010
from pylons import request, session, tmpl_context as c, url, app_globals as g, \
config
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
HasPermissionAnyDecorator, NotAnonymous
from rhodecode.lib.celerylib import tasks, run_task
from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
rhodecode.controllers.admin.users
Users crud controller for pylons
:created_on: Apr 4, 2010
from rhodecode.lib.exceptions import *
rhodecode.controllers.branches
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
branches controller for rhodecode
:created_on: Apr 21, 2010
from pylons import tmpl_context as c
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
from rhodecode.lib.utils import OrderedDict
from rhodecode.model.scm import ScmModel
rhodecode.controllers.changelog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
changelog controller for rhodecode
try:
import json
except ImportError:
#python 2.5 compatibility
import simplejson as json
from mercurial.graphmod import colored, CHANGESET, revisions as graph_rev
from pylons import request, session, tmpl_context as c
rhodecode.controllers.changeset
changeset controller for pylons
:created_on: Apr 25, 2010
from pylons import tmpl_context as c, url, request, response
from pylons.controllers.util import redirect
import rhodecode.lib.helpers as h
from rhodecode.lib.utils import EmptyChangeset
package.rhodecode.controllers.error
~~~~~~~~~~~~~~
RhodeCode error controller
:created_on: Dec 8, 2010
import os
import cgi
import paste.fileapp
from pylons import tmpl_context as c, request, config
from pylons.middleware import media_path
rhodecode.controllers.feed
~~~~~~~~~~~~~~~~~~~~~~~~~~
Feed controller for rhodecode
:created_on: Apr 23, 2010
from pylons import url, response
from rhodecode.lib.base import BaseController
from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
rhodecode.controllers.files
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Files controller for RhodeCode
import tempfile
from mercurial import archival
rhodecode.controllers.home
Home controller for Rhodecode
:created_on: Feb 18, 2010
from pylons import tmpl_context as c, request
from rhodecode.lib.auth import LoginRequired
rhodecode.controllers.journal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Journal controller for pylons
:created_on: Nov 21, 2010
from paste.httpexceptions import HTTPInternalServerError, HTTPBadRequest
from sqlalchemy import or_
from rhodecode.lib.auth import LoginRequired, NotAnonymous
from rhodecode.lib.helpers import get_token
rhodecode.controllers.login
Login controller for rhodeocode
:created_on: Apr 22, 2010
from rhodecode.lib.auth import AuthUser, HasPermissionAnyDecorator
rhodecode.controllers.search
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Search controller for rhodecode
:created_on: Aug 7, 2010
from pylons import request, response, config, session, tmpl_context as c, url
from rhodecode.lib.indexers import SCHEMA, IDX_NAME, ResultWrapper
rhodecode.controllers.settings
Settings controller for rhodecode
:created_on: Jun 30, 2010
from pylons import tmpl_context as c, request, url
rhodecode.controllers.shortlog
Shortlog controller for rhodecode
:created_on: Apr 18, 2010
rhodecode.controllers.summary
Summary controller for Rhodecode
import calendar
from time import mktime
from datetime import datetime, timedelta, date
from vcs.exceptions import ChangesetError
rhodecode.controllers.tags
Tags controller for rhodecode
class TagsController(BaseController):
rhodecode.lib.auth
~~~~~~~~~~~~~~~~~~
authentication and permission libraries
:copyright: (c) 2010 by marcink.
:license: LICENSE_NAME, see LICENSE_FILE for more details.
import random
from decorator import decorator
from pylons import config, session, url, request
from rhodecode import __platform__, PLATFORM_WIN, PLATFORM_OTHERS
#!/usr/bin/env python
# encoding: utf-8
# ldap authentication lib
# Copyright (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
Created on Nov 17, 2010
@author: marcink
# mercurial repository backup manager
# Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
Created on Feb 28, 2010
Mercurial repositories backup manager
import tarfile
import datetime
package.rhodecode.lib.celerylib.__init__
celery libs for RhodeCode
:created_on: Nov 27, 2010
import sys
import socket
from hashlib import md5
from vcs.utils.lazy import LazyProperty
from rhodecode.lib.pidlock import DaemonLock, LockHeld
@@ -2,38 +2,36 @@
rhodecode.lib.celerylib.tasks
RhodeCode task modules, containing all task that suppose to be run
by celery daemon
:created_on: Oct 6, 2010
from celery.decorators import task
from pylons import config
rhodecode.lib.dbmigrate.__init__
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database migration modules
:created_on: Dec 11, 2010
from sqlalchemy import engine_from_config
from rhodecode.lib.utils import BasePasterCommand, Command, add_cache
from rhodecode.lib.db_manage import DbManage
class UpgradeDb(BasePasterCommand):
"""Command used for paster to upgrade our database to newer version
rhodecode.lib.dbmigrate.versions.__init__
Package containing new versions of database models
# Custom Exceptions modules
Custom Exceptions modules
class LdapUsernameError(Exception):pass
class LdapPasswordError(Exception):pass
class LdapConnectionError(Exception):pass
class LdapImportError(Exception):pass
class DefaultUserException(Exception):pass
rhodecode.lib.hooks
~~~~~~~~~~~~~~~~~~~
Hooks runned by rhodecode
:created_on: Aug 6, 2010
import getpass
from mercurial.cmdutil import revrange
from mercurial.node import nullrev
from rhodecode.lib.utils import action_logger
def repo_size(ui, repo, hooktype=None, **kwargs):
"""Presents size of repository after push
# whoosh indexer daemon for rhodecode
Created on Jan 26, 2010
A deamon will read from task table and run tasks
from os.path import dirname as dn
from os.path import join as jn
#to get the rhodecode import
rhodecode.lib.middleware.https_fixup
middleware to handle https correctly
:created_on: May 23, 2010
from rhodecode.lib import str2bool
class HttpsFixup(object):
def __init__(self, app, config):
self.application = app
self.config = config
def __call__(self, environ, start_response):
self.__fixup(environ)
return self.application(environ, start_response)
# middleware to handle git api calls
Created on 2010-04-28
SimpleGit middleware for handling git protocol request (push/clone etc.)
It's implemented with basic auth function
from dulwich import server as dulserver
class SimpleGitUploadPackHandler(dulserver.UploadPackHandler):
# middleware to handle mercurial api calls
SimpleHG middleware for handling mercurial protocol request (push/clone etc.)
from mercurial.error import RepoError
from mercurial.hgweb import hgweb
from mercurial.hgweb.request import wsgiapplication
from paste.auth.basic import AuthBasicAuthenticator
from paste.httpheaders import REMOTE_USER, AUTH_TYPE
rhodecode.lib.utils
Utilities library for RhodeCode
from UserDict import DictMixin
from mercurial import ui, config, hg
import paste
@@ -19,38 +19,36 @@
from rhodecode.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
from rhodecode.model import meta
def init_model(engine):
"""Initializes db session, bind the engine with the metadata,
Call this before using any of the tables or classes in the model, preferably
once in application start
:param engine: engine to bind to
rhodecode.model.db
Database Models for RhodeCode
:created_on: Apr 08, 2010
from datetime import date
from sqlalchemy import *
from sqlalchemy.exc import DatabaseError
from sqlalchemy.orm import relationship, backref
from sqlalchemy.orm.interfaces import MapperExtension
from rhodecode.model.meta import Base, Session
rhodecode.model.permission
permissions model for RhodeCode
:created_on: Aug 20, 2010
from rhodecode.model import BaseModel
from rhodecode.model.db import User, Permission, UserToPerm, RepoToPerm
from rhodecode.model.caching_query import FromCache
rhodecode.model.repo
~~~~~~~~~~~~~~~~~~~~
Repository model for rhodecode
:created_on: Jun 5, 2010
import shutil
from datetime import datetime
from sqlalchemy.orm import joinedload, make_transient
from vcs.backends import get_backend
rhodecode.model.settings
~~~~~~~~~~~~~~~~~~~~~~~~
Settings model for RhodeCode
:created on Nov 17, 2010
from rhodecode.model.db import RhodeCodeSettings
class SettingsModel(BaseModel):
Settings model
rhodecode.model.user
users model for RhodeCode
:created_on: Apr 9, 2010
from rhodecode.model.db import User
from rhodecode.lib.exceptions import DefaultUserException, UserOwnsReposException
Status change: