Changeset - 6b934c9607e7
[Not reviewed]
pylons_app/config/environment.py
Show inline comments
 
@@ -40,25 +40,28 @@ def load_environment(global_conf, app_co
 
    pylons.cache._push_object(config['pylons.app_globals'].cache)
 
    
 
    # Create the Mako TemplateLookup, with the default auto-escaping
 
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
 
        directories=paths['templates'],
 
        error_handler=handle_mako_error,
 
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
 
        input_encoding='utf-8', default_filters=['escape'],
 
        imports=['from webhelpers.html import escape'])
 

	
 
    #sets the c attribute access when don't existing attribute are accessed
 
    config['pylons.strict_tmpl_context'] = True
 
    test = os.path.split(config['__file__'])[-1] == 'tests.ini'
 
    test = os.path.split(config['__file__'])[-1] == 'test.ini'
 
    if test:
 
        from pylons_app.lib.utils import make_test_env
 
        make_test_env()
 
    #MULTIPLE DB configs
 
    # Setup the SQLAlchemy database engine
 
    if config['debug'] and not test:
 
        #use query time debugging.
 
        from pylons_app.lib.timerproxy import TimerProxy
 
        sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.',
 
                                                            proxy=TimerProxy())
 
    else:
 
        sa_engine_db1 = engine_from_config(config, 'sqlalchemy.db1.')
 

	
 
    init_model(sa_engine_db1)
 
    #init baseui
pylons_app/controllers/admin/settings.py
Show inline comments
 
@@ -97,25 +97,25 @@ class SettingsController(BaseController)
 
        if setting_id == 'mapping':
 
            rm_obsolete = request.POST.get('destroy', False)
 
            log.debug('Rescanning directories with destroy=%s', rm_obsolete)
 

	
 
            initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui)
 
            repo2db_mapper(initial, rm_obsolete)
 
            invalidate_cache('cached_repo_list')
 
            h.flash(_('Repositories sucessfully rescanned'), category='success')            
 
        
 
        if setting_id == 'whoosh':
 
            repo_location = get_hg_ui_settings()['paths_root_path']
 
            full_index = request.POST.get('full_index',False)
 
            task = run_task(tasks.whoosh_index,True,repo_location,full_index)
 
            task = run_task(tasks.whoosh_index,repo_location,full_index)
 
            
 
            h.flash(_('Whoosh reindex task scheduled'), category='success')
 
        if setting_id == 'global':
 
            
 
            application_form = ApplicationSettingsForm()()
 
            try:
 
                form_result = application_form.to_python(dict(request.POST))
 
            
 
                try:
 
                    hgsettings1 = self.sa.query(HgAppSettings)\
 
                    .filter(HgAppSettings.app_settings_name == 'title').one()
 
                    hgsettings1.app_settings_value = form_result['hg_app_title'] 
pylons_app/controllers/summary.py
Show inline comments
 
@@ -52,19 +52,19 @@ class SummaryController(BaseController):
 
                                        'user':str(c.hg_app_user.username),
 
                                        'host':e.get('HTTP_HOST'),
 
                                        'repo_name':c.repo_name, }
 
        c.clone_repo_url = uri
 
        c.repo_tags = OrderedDict()
 
        for name, hash in c.repo_info.tags.items()[:10]:
 
            c.repo_tags[name] = c.repo_info.get_changeset(hash)
 
        
 
        c.repo_branches = OrderedDict()
 
        for name, hash in c.repo_info.branches.items()[:10]:
 
            c.repo_branches[name] = c.repo_info.get_changeset(hash)
 
        
 
        task = run_task(get_commits_stats,False,c.repo_info.name)
 
        task = run_task(get_commits_stats,c.repo_info.name)
 
        c.ts_min = task.result[0]
 
        c.ts_max = task.result[1]
 
        c.commit_data = task.result[2]
 
        
 
        return render('summary/summary.html')
 

	
pylons_app/lib/utils.py
Show inline comments
 
@@ -7,39 +7,42 @@
 
# 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 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.
 
import shutil
 

	
 
"""
 
Created on April 18, 2010
 
Utilities for hg app
 
@author: marcink
 
"""
 
from beaker.cache import cache_region
 
from mercurial import ui, config, hg
 
from mercurial.error import RepoError
 
from pylons_app.model import meta
 
from pylons_app.model.db import Repository, User, HgAppUi, HgAppSettings
 
from vcs.backends.base import BaseChangeset
 
from vcs.utils.lazy import LazyProperty
 
import logging
 
import os
 
from os.path import dirname as dn, join as jn
 
import tarfile
 
log = logging.getLogger(__name__)
 

	
 

	
 
def get_repo_slug(request):
 
    return request.environ['pylons.routes_dict'].get('repo_name')
 

	
 
def is_mercurial(environ):
 
    """
 
    Returns True if request's target is mercurial server - header
 
    ``HTTP_ACCEPT`` of such request would start with ``application/mercurial``.
 
    """
 
    http_accept = environ.get('HTTP_ACCEPT')
 
@@ -353,12 +356,76 @@ class OrderedDict(dict, DictMixin):
 
        d = cls()
 
        for key in iterable:
 
            d[key] = value
 
        return d
 

	
 
    def __eq__(self, other):
 
        if isinstance(other, OrderedDict):
 
            return len(self) == len(other) and self.items() == other.items()
 
        return dict.__eq__(self, other)
 

	
 
    def __ne__(self, other):
 
        return not self == other
 

	
 
def make_test_env():
 
    """Makes a fresh database from base64+zlib dump and 
 
    install test repository into tmp dir
 
    """
 
    new_db_dump = """
 
eJztXN1vE8sVn9nxR+wAIXDpFiiXjSAXfEOc2ElwQkVLPjYf5NNOAklUydrYG3tv1t5ldx0nuUJV\noL
 
cPrVr1X7jSfUJ96nMfK1Xty23VqlWlPlRIlahUXbXqFUL0pTNjx5614xAoKEDmJ3t2zpkzM2fO\neHe+
 
zno+PqU5qrRmWDnFkXqAB0AIbkkSAKANf8+BKprwFzI0G28ECXQ+PufFEYT+Tehz6L/oaSnK\nwcFxGP
 
igFQfHjuMg4CehH7UA9Af0Y2ShWdSPLmOSg+N9x7U9eKf9PiC2nIWm4mTtri4nZ3Z9DE/5\nfOD0+RZY
 
VFdXFVstWHoXPOPFvDbKU3TdKCbNgp39GLZ5MPtKW5WtWKmstqFmtqVtzZRWt6NQRFjk\ngkhESJ6kbe
 
trim6rcFTAdcfuwqxhrNuprJLPqBnLKJhhSzWNpK1tq+aWkzXyN8wt3cjbScU0w7q2\nGqbyV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f1ICXlUTsgzw/L87vpuj4XRrubsOjN2zCdOtjfqJNac
 
yQhLtcSOHzhj\nlKVOlsb/fwL0FAccHBzvLQJIhHRpIJAYXRPQ8R+i3wP84eDgeNfRCX3gAoRjGyk7Sc
 
78BUDPZdlJ\n0ZphSbvJZPyH6D8Afzg4ON5/HEMX4O7tD0v3/3OAPxwcHEcG1f0/hJ4A9Az9C184ODje
 
Q/gQ+WcP\nKPgEevX5IL0GyPiP0Fdl/7/D1pKDg+PNYe/3f+j4/wSP/88OWz8ODo43Ab+H3O0CKl19Qu
 
kaoPN/\nD/gcgM+FD4W7ws8OW886PNg+UTp4jlX8aJOOQR0a2XhrnVftbkrFubZM7+dkewA/zgYS9a6x
 
1erq\nXWRr0thDZLdfJ3uU7PI+rXcMfYWT6Bq33WtSrVNprGW/Y2VXUyIsdSp28sAZoyx1+kGulXqTfx
 
aq\ndrduZOxK5Ex9RxN2pZcx8So9XEozKw4D1Vdn6v0RFLdfeolM0r/U2d9buqRbvekZ/iv0IpulqrYr
 
\nl9sRo+rBEAyR+x8/ADg4OI4gyPyf3/8cHEcTJf+fpwB/ODg4jgSaoBfQ/QB+/s/BcSRR3f+H6Bng\n
 
e/8cHEcHpf1/CI+jHwEP3AToLtx8e9/9e//w8Hun6bHGDz+tvE+3uwfOxsW69+nYYw2WfjPHGtX9\n5A
 
MdfNQo9P+eS7youNdyVuJq4ot2zRsdnLgLCYYip/b7w5jKqUX51IREv4F/FJ7YBy96ja963sJS\n34yd
 
OXDGKEud/R8efZUt\n
 
"""    
 
    newdb = open('test.db','wb')
 
    newdb.write(new_db_dump.decode('base64').decode('zlib'))
 
    newdb.close()
 
    
 
    
 
    #PART TWO make test repo
 
    if os.path.isdir('/tmp/vcs_test'):
 
        shutil.rmtree('/tmp/vcs_test')
 
        
 
    cur_dir = dn(dn(os.path.abspath(__file__)))
 
    tar = tarfile.open(jn(cur_dir,'tests',"vcs_test.tar.gz"))
 
    tar.extractall('/tmp')
 
    tar.close()
 
    
 
    
pylons_app/model/__init__.py
Show inline comments
 
"""The application's model objects"""
 
import logging
 
import sqlalchemy as sa
 
from sqlalchemy import orm
 
from pylons_app.model import meta
 
from pylons_app.model.meta import Session
 
log = logging.getLogger(__name__)
 

	
 
# Add these two imports:
 
import datetime
 
from sqlalchemy import schema, types
 

	
 
def init_model(engine):
 
    """Call me before using any of the tables or classes in the model"""
 
    log.info("INITIALIZING DB MODELS")
 
    meta.Base.metadata.bind = engine
 
    #meta.Base2.metadata.bind = engine2
 

	
 
#THIS IS A TEST FOR EXECUTING SCRIPT AND LOAD PYLONS APPLICATION GLOBALS
 
#from paste.deploy import appconfig
 
#from pylons import config
 
#from sqlalchemy import engine_from_config
 
#from pylons_app.config.environment import load_environment
 
#
pylons_app/model/db.py
Show inline comments
 
@@ -17,25 +17,25 @@ class HgAppSettings(Base):
 
class HgAppUi(Base):
 
    __tablename__ = 'hg_app_ui'
 
    __table_args__ = {'useexisting':True}
 
    ui_id = Column("ui_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
 
    ui_section = Column("ui_section", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    ui_key = Column("ui_key", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    ui_value = Column("ui_value", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    ui_active = Column("ui_active", BOOLEAN(), nullable=True, unique=None, default=True)
 
    
 
    
 
class User(Base): 
 
    __tablename__ = 'users'
 
    __table_args__ = (UniqueConstraint('username'), {'useexisting':True})
 
    __table_args__ = (UniqueConstraint('username'), UniqueConstraint('email'), {'useexisting':True})
 
    user_id = Column("user_id", INTEGER(), nullable=False, unique=True, default=None, primary_key=True)
 
    username = Column("username", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    password = Column("password", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    active = Column("active", BOOLEAN(), nullable=True, unique=None, default=None)
 
    admin = Column("admin", BOOLEAN(), nullable=True, unique=None, default=False)
 
    name = Column("name", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    lastname = Column("lastname", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    email = Column("email", TEXT(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None)
 
    last_login = Column("last_login", DATETIME(timezone=False), nullable=True, unique=None, default=None)
 
    
 
    user_log = relation('UserLog')
 
    user_perms = relation('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id")
pylons_app/model/hg_model.py
Show inline comments
 
@@ -93,25 +93,25 @@ class HgModel(object):
 
        sa = meta.Session()
 
        def check_repo_dir(path):
 
            """
 
            Checks the repository
 
            :param path:
 
            """
 
            repos_path = path.split('/')
 
            if repos_path[-1] in ['*', '**']:
 
                repos_path = repos_path[:-1]
 
            if repos_path[0] != '/':
 
                repos_path[0] = '/'
 
            if not os.path.isdir(os.path.join(*repos_path)):
 
                raise RepositoryError('Not a valid repository in %s' % path[0][1])        
 
                raise RepositoryError('Not a valid repository in %s' % path)        
 
        if not repos_path.endswith('*'):
 
            raise VCSError('You need to specify * or ** at the end of path '
 
                            'for recursive scanning')
 
            
 
        check_repo_dir(repos_path)
 
        log.info('scanning for repositories in %s', repos_path)
 
        repos = findrepos([(repos_prefix, repos_path)])
 
        if not isinstance(baseui, ui.ui):
 
            baseui = ui.ui()
 
    
 
        repos_list = {}
 
        for name, path in repos:
pylons_app/tests/__init__.py
Show inline comments
 
@@ -7,39 +7,42 @@ command.
 
This module initializes the application via ``websetup`` (`paster
 
setup-app`) and provides the base testing objects.
 
"""
 
from unittest import TestCase
 

	
 
from paste.deploy import loadapp
 
from paste.script.appinstall import SetupCommand
 
from pylons import config, url
 
from routes.util import URLGenerator
 
from webtest import TestApp
 
import os
 
from pylons_app.model import meta
 
import logging
 
log = logging.getLogger(__name__) 
 

	
 
import pylons.test
 

	
 
__all__ = ['environ', 'url', 'TestController']
 

	
 
# Invoke websetup with the current config file
 
SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
 
#SetupCommand('setup-app').run([pylons.test.pylonsapp.config['__file__']])
 

	
 
environ = {}
 

	
 
class TestController(TestCase):
 

	
 
    def __init__(self, *args, **kwargs):
 
        wsgiapp = pylons.test.pylonsapp
 
        config = wsgiapp.config
 
        self.app = TestApp(wsgiapp)
 
        url._push_object(URLGenerator(config['routes.map'], environ))
 
        self.sa = meta.Session
 
        TestCase.__init__(self, *args, **kwargs)
 

	
 
    
 
    def log_user(self):
 
        response = self.app.post(url(controller='login', action='index'),
 
                                 {'username':'test_admin',
 
                                  'password':'test'})
 
        assert response.status == '302 Found', 'Wrong response code from login got %s' % response.status
 
        assert response.session['hg_app_user'].username == 'test_admin', 'wrong logged in user'
 
        return response.follow()        
 
\ No newline at end of file
 
        return response.follow()
pylons_app/tests/functional/test_admin.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestAdminController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='admin/admin', action='index'))
 
        assert 'Admin dashboard - journal' in response.body,'No proper title in dashboard'
 
        # Test response...
pylons_app/tests/functional/test_branches.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestBranchesController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='branches', action='index',repo_name='vcs_test'))
 
        # Test response...
pylons_app/tests/functional/test_changelog.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestChangelogController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='changelog', action='index',repo_name='vcs_test'))
 
        # Test response...
pylons_app/tests/functional/test_feed.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestFeedController(TestController):
 

	
 
    def test_rss(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='feed', action='rss',
 
                                    repo_name='vcs_test'))
 
        # Test response...
 

	
 
    def test_atom(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='feed', action='atom',
 
                                    repo_name='vcs_test'))
 
        # Test response...
 
\ No newline at end of file
pylons_app/tests/functional/test_files.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestFilesController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='files', action='index',
 
                                    repo_name='vcs_test',
 
                                    revision='tip',
 
                                    f_path='/'))
 
        # Test response...
pylons_app/tests/functional/test_login.py
Show inline comments
 
@@ -73,39 +73,67 @@ class TestLoginController(TestController
 
                                             'email':'goodmailm',
 
                                             'name':'test',
 
                                             'lastname':'test'})
 
        
 
        assert response.status == '200 OK', 'Wrong response from register page got %s' % response.status
 
        assert 'An email address must contain a single @' in response.body
 
        assert 'Enter a value 3 characters long or more' in response.body
 
        assert 'Please enter a value<' in response.body
 
        
 
        
 
        
 
    def test_register_ok(self):
 
        username = 'test_regular2'
 
        username = 'test_regular4'
 
        password = 'qweqwe'
 
        email = 'goodmail@mail.com'
 
        email = 'marcin@somemail.com'
 
        name = 'testname'
 
        lastname = 'testlastname'
 
        
 
        response = self.app.post(url(controller='login', action='register'),
 
                                            {'username':username,
 
                                             'password':password,
 
                                             'email':email,
 
                                             'name':name,
 
                                             'lastname':lastname})
 
        
 
        print response.body
 
        assert response.status == '302 Found', 'Wrong response from register page got %s' % response.status        
 
        assert 'You have successfully registered into hg-app' in response.session['flash'][0], 'No flash message about user registration'
 
        
 
        ret = self.sa.query(User).filter(User.username == 'test_regular2').one()
 
        ret = self.sa.query(User).filter(User.username == 'test_regular4').one()
 
        assert ret.username == username , 'field mismatch %s %s' % (ret.username, username)
 
        assert check_password(password,ret.password) == True , 'password mismatch'
 
        assert ret.email == email , 'field mismatch %s %s' % (ret.email, email)
 
        assert ret.name == name , 'field mismatch %s %s' % (ret.name, name)
 
        assert ret.lastname == lastname , 'field mismatch %s %s' % (ret.lastname, lastname)
 
    
 
        
 
    def test_forgot_password_wrong_mail(self):    
 
        response = self.app.post(url(controller='login', action='password_reset'),
 
                                            {'email':'marcin@wrongmail.org',})
 
        
 
        assert "That e-mail address doesn't exist" in response.body,'Missing error message about wrong email'
 
                
 
    def test_forgot_password(self):
 
        response = self.app.get(url(controller='login', action='password_reset'))
 
        assert response.status == '200 OK', 'Wrong response from login page got %s' % response.status
 

	
 
        username = 'test_password_reset_1'
 
        password = 'qweqwe'
 
        email = 'marcin@python-works.com'
 
        name = 'passwd'
 
        lastname = 'reset'
 
                
 
        response = self.app.post(url(controller='login', action='register'),
 
                                            {'username':username,
 
                                             'password':password,
 
                                             'email':email,
 
                                             'name':name,
 
                                             'lastname':lastname})        
 
        #register new user for email test
 
        response = self.app.post(url(controller='login', action='password_reset'),
 
                                            {'email':email,})
 
        print response.session['flash']
 
        assert 'You have successfully registered into hg-app' in response.session['flash'][0], 'No flash message about user registration'
 
        assert 'Your new password was sent' in response.session['flash'][1], 'No flash message about password reset'
 
        
 
        
 
        
 
        
pylons_app/tests/functional/test_settings.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestSettingsController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='settings', action='index',
 
                                    repo_name='vcs_test'))
 
        # Test response...
pylons_app/tests/functional/test_shortlog.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestShortlogController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='shortlog', action='index',repo_name='vcs_test'))
 
        # Test response...
pylons_app/tests/functional/test_summary.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestSummaryController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='summary', action='index',repo_name='vcs_test'))
 
        # Test response...
pylons_app/tests/functional/test_tags.py
Show inline comments
 
from pylons_app.tests import *
 

	
 
class TestTagsController(TestController):
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url(controller='tags', action='index',repo_name='vcs_test'))
 
        # Test response...
pylons_app/websetup.py
Show inline comments
 
"""Setup the pylons_app application"""
 

	
 
from os.path import dirname as dn, join as jn
 
from os.path import dirname as dn
 
from pylons_app.config.environment import load_environment
 
from pylons_app.lib.db_manage import DbManage
 
import datetime
 
from time import mktime
 
import logging
 
import os
 
import sys
 
import tarfile
 

	
 
log = logging.getLogger(__name__)
 

	
 
ROOT = dn(dn(os.path.realpath(__file__)))
 
sys.path.append(ROOT)
 

	
 

	
 
def setup_app(command, conf, vars):
 
    """Place any commands to setup pylons_app here"""
 
    log_sql = True
 
    tests = False
 
    REPO_TEST_PATH = None
 
    
 
    dbname = os.path.split(conf['sqlalchemy.db1.url'])[-1]
 
    filename = os.path.split(conf.filename)[-1]
 
    
 
    if filename == 'tests.ini':
 
        uniq_suffix = str(int(mktime(datetime.datetime.now().timetuple())))
 
        REPO_TEST_PATH = '/tmp/hg_app_test_%s' % uniq_suffix
 
        
 
        if not os.path.isdir(REPO_TEST_PATH):
 
            os.mkdir(REPO_TEST_PATH)
 
            cur_dir = dn(os.path.abspath(__file__))
 
            tar = tarfile.open(jn(cur_dir,'tests',"vcs_test.tar.gz"))
 
            tar.extractall(REPO_TEST_PATH)
 
            tar.close()
 
            
 
        tests = True    
 
#    filename = os.path.split(conf.filename)[-1]
 
#    if filename == 'test.ini':
 
#        uniq_suffix = str(int(mktime(datetime.datetime.now().timetuple())))
 
#        REPO_TEST_PATH = '/tmp/hg_app_test_%s' % uniq_suffix
 
#        
 
#        if not os.path.isdir(REPO_TEST_PATH):
 
#            os.mkdir(REPO_TEST_PATH)
 
#            cur_dir = dn(os.path.abspath(__file__))
 
#            tar = tarfile.open(jn(cur_dir,'tests',"vcs_test.tar.gz"))
 
#            tar.extractall(REPO_TEST_PATH)
 
#            tar.close()
 
#            
 
#        tests = True    
 
    
 
    dbmanage = DbManage(log_sql, dbname, tests)
 
    dbmanage.create_tables(override=True)
 
    dbmanage.config_prompt(REPO_TEST_PATH)
 
    dbmanage.create_default_user()
 
    dbmanage.admin_prompt()
 
    dbmanage.create_permissions()
 
    dbmanage.populate_default_permissions()
 
    load_environment(conf.global_conf, conf.local_conf, initial=True)
 

	
setup.cfg
Show inline comments
 
[egg_info]
 
tag_build = dev
 
tag_svn_revision = true
 

	
 
[easy_install]
 
find_links = http://www.pylonshq.com/download/
 

	
 
[nosetests]
 
verbose=True
 
verbosity=2
 
with-pylons=tests.ini
 
with-pylons=test.ini
 
detailed-errors=1
 

	
 
# Babel configuration
 
[compile_catalog]
 
domain = pylons_app
 
directory = pylons_app/i18n
 
statistics = true
 

	
 
[extract_messages]
 
add_comments = TRANSLATORS:
 
output_file = pylons_app/i18n/pylons_app.pot
 
width = 80
test.ini
Show inline comments
 
file renamed from tests.ini to test.ini
0 comments (0 inline, 0 general)