コード例 #1
0
    def test_site_notification_update(self):
        active = 'True'
        impressions = '7'
        content = 'test1'
        user_role = 'test2'
        page_regex = 'test3'
        page_tool_type = 'test4'

        note = M.notification.SiteNotification(active=False,
                                               impressions=0,
                                               content='test')
        ThreadLocalORMSession().flush_all()

        count = M.notification.SiteNotification.query.find().count()

        r = self.app.post('/nf/admin/site_notifications/{}/update'.format(note._id), params=dict(
            active=active,
            impressions=impressions,
            content=content,
            user_role=user_role,
            page_regex=page_regex,
            page_tool_type=page_tool_type))
        ThreadLocalORMSession().flush_all()

        note = M.notification.SiteNotification.query.find().sort('_id', -1).next()

        assert '/nf/admin/site_notifications' in r.location
        assert M.notification.SiteNotification.query.find().count() == count
        assert note.active == bool('True')
        assert note.impressions == int(impressions)
        assert note.content == content
        assert note.user_role == user_role
        assert note.page_regex == page_regex
        assert note.page_tool_type == page_tool_type
コード例 #2
0
ファイル: test_site_admin.py プロジェクト: xmonader/allura
    def test_send_password_reset_link(self, gen_message_id, sendmail):
        user = M.User.by_username('test-user')
        user.set_pref('email_address', '*****@*****.**')
        M.EmailAddress(email='*****@*****.**',
                       confirmed=True,
                       claimed_by_user_id=user._id)
        ThreadLocalORMSession.flush_all()
        with td.audits('Password recovery link sent to: [email protected]',
                       user=True):
            r = self.app.post('/nf/admin/user/send_password_reset_link',
                              params={'username': '******'})
        hash = user.get_tool_data('AuthPasswordReset', 'hash')
        text = '''Your username is test-user

To update your password on %s, please visit the following URL:

%s/auth/forgotten_password/%s''' % (config['site_name'], config['base_url'],
                                    hash)
        sendmail.post.assert_called_once_with(
            sender='noreply@localhost',
            toaddr='*****@*****.**',
            fromaddr='"{}" <{}>'.format(config['site_name'],
                                        config['forgemail.return_path']),
            reply_to=config['forgemail.return_path'],
            subject='Allura Password recovery',
            message_id=gen_message_id(),
            text=text)
コード例 #3
0
    def test_disable_user(self):
        # user was not pending
        assert_equal(M.User.by_username('test-user-3').disabled, False)
        assert_equal(M.User.by_username('test-user-3').pending, False)
        r = self.app.get('/nf/admin/user/test-user-3')
        form = r.forms[0]
        assert_equal(form['username'].value, 'test-user-3')
        assert_equal(form['status'].value, 'enable')
        form['status'].value = 'disable'
        with td.audits('Account disabled', user=True):
            r = form.submit()
            assert_equal(M.AuditLog.query.find().count(), 1)
        assert_in(u'User disabled', self.webflash(r))
        assert_equal(M.User.by_username('test-user-3').disabled, True)
        assert_equal(M.User.by_username('test-user-3').pending, False)

        # user was pending
        user = M.User.by_username('test-user-3')
        user.disabled = False
        user.pending = True
        ThreadLocalORMSession.flush_all()
        assert_equal(M.User.by_username('test-user-3').disabled, False)
        assert_equal(M.User.by_username('test-user-3').pending, True)
        r = self.app.get('/nf/admin/user/test-user-3')
        form = r.forms[0]
        assert_equal(form['username'].value, 'test-user-3')
        assert_equal(form['status'].value, 'pending')
        form['status'].value = 'disable'
        with td.audits('Account disabled', user=True):
            r = form.submit()
            assert_equal(M.AuditLog.query.find().count(), 1)
        assert_in(u'User disabled', self.webflash(r))
        assert_equal(M.User.by_username('test-user-3').disabled, True)
        assert_equal(M.User.by_username('test-user-3').pending, True)
コード例 #4
0
    def test_disable_user(self):
        # user was not pending
        assert_equal(M.User.by_username('test-user-3').disabled, False)
        assert_equal(M.User.by_username('test-user-3').pending, False)
        r = self.app.get('/nf/admin/user/test-user-3')
        form = r.forms[0]
        assert_equal(form['username'].value, 'test-user-3')
        assert_equal(form['status'].value, 'enable')
        form['status'].value = 'disable'
        with td.audits('Account disabled', user=True):
            r = form.submit()
            assert_equal(M.AuditLog.query.find().count(), 1)
        assert_in(u'User disabled', self.webflash(r))
        assert_equal(M.User.by_username('test-user-3').disabled, True)
        assert_equal(M.User.by_username('test-user-3').pending, False)

        # user was pending
        user = M.User.by_username('test-user-3')
        user.disabled = False
        user.pending = True
        ThreadLocalORMSession.flush_all()
        assert_equal(M.User.by_username('test-user-3').disabled, False)
        assert_equal(M.User.by_username('test-user-3').pending, True)
        r = self.app.get('/nf/admin/user/test-user-3')
        form = r.forms[0]
        assert_equal(form['username'].value, 'test-user-3')
        assert_equal(form['status'].value, 'pending')
        form['status'].value = 'disable'
        with td.audits('Account disabled', user=True):
            r = form.submit()
            assert_equal(M.AuditLog.query.find().count(), 1)
        assert_in(u'User disabled', self.webflash(r))
        assert_equal(M.User.by_username('test-user-3').disabled, True)
        assert_equal(M.User.by_username('test-user-3').pending, True)
コード例 #5
0
 def execute(cls, options):
     duplicates = cls._find_duplicates()
     log.info('Found %s duplicate categories: %s', len(duplicates), duplicates.keys())
     for name, dups in duplicates.iteritems():
         projects_with_category = {}
         for dup in dups:
             projects = cls._projects_with_category(dup._id)
             projects_with_category[dup._id] = projects
         log.info('Following projects are using category %s:', name)
         for _id, ps in projects_with_category.iteritems():
             log.info('  with id %s: %s', _id, [p.shortname for p in ps])
         priority = [(i, len(ps)) for i, ps in projects_with_category.items()]
         priority = sorted(priority, key=itemgetter(1), reverse=True)
         priority = [p[0] for p in priority]
         live, kill = priority[0], priority[1:]
         log.info('%s will live %s will die', live, kill)
         if sum([len(projects_with_category[_id]) for _id in kill]) > 0:
             # Duplicates are used somewhere, need to reasign for all projects that use them
             projects = []
             ids_to_kill = set(kill)
             for p in [projects_with_category[_id] for _id in kill]:
                 projects.extend(p)
             for p in projects:
                 for tt in cls.trove_types:
                     _ids = ids_to_kill.intersection(getattr(p, tt))
                     for _id in _ids:
                         log.info('Removing %s from %s.%s and adding %s instead', _id, p.shortname, tt, live)
                         if not options.dry_run:
                             getattr(p, tt).remove(_id)
                             getattr(p, tt).append(live)
         log.info('Removing categories %s', kill)
         if not options.dry_run:
             M.TroveCategory.query.remove({'_id': {'$in': kill}})
         ThreadLocalORMSession.flush_all()
コード例 #6
0
def main():
    for chunk in utils.chunked_find(M.User):
        for user in chunk:
            print 'Processing {0}'.format(user.username)
            user.pending = False
            # Ming doesn't mark document for update, since pending is False
            # by default, even if field is missing from mongo
            state(user).status = state(user).dirty
            ThreadLocalORMSession.flush_all()
コード例 #7
0
def main():
    for chunk in utils.chunked_find(M.MergeRequest):
        for mr in chunk:
            try:
                print 'Processing {0}'.format(mr.url())
                mr.subscribe(user=mr.creator)
                ThreadLocalORMSession.flush_all()
            except:
                log.exception('Error on %s', mr)
コード例 #8
0
def main():
    for chunk in utils.chunked_find(M.MergeRequest):
        for mr in chunk:
            try:
                print('Processing {0}'.format(mr.url()))
                mr.subscribe(user=mr.creator)
                ThreadLocalORMSession.flush_all()
            except:
                log.exception('Error on %s', mr)
コード例 #9
0
def main():
    for chunk in utils.chunked_find(M.User):
        for user in chunk:
            print 'Processing {0}'.format(user.username)
            user.pending = False
            # Ming doesn't mark document for update, since pending is False
            # by default, even if field is missing from mongo
            state(user).status = state(user).dirty
            ThreadLocalORMSession.flush_all()
コード例 #10
0
ファイル: test_forum.py プロジェクト: xmonader/allura
 def test_is_spam(self, spam_checker):
     spam_checker.check.return_value = True
     c.user = M.User.query.get(username="******")
     role = M.ProjectRole(project_id=c.project._id, name='TestRole')
     M.ProjectRole.by_user(c.user, upsert=True).roles.append(role._id)
     ThreadLocalORMSession.flush_all()
     t = M.Thread()
     p = M.Post(thread=t)
     assert_in('TestRole', [r.name for r in c.project.named_roles])
     assert_false(t.is_spam(p))
コード例 #11
0
ファイル: test_forum.py プロジェクト: dastanforever/allura
 def test_is_spam(self, spam_checker):
     spam_checker.check.return_value = True
     c.user = M.User.query.get(username="******")
     role = M.ProjectRole(project_id=c.project._id, name='TestRole')
     M.ProjectRole.by_user(c.user, upsert=True).roles.append(role._id)
     ThreadLocalORMSession.flush_all()
     t = M.Thread()
     p = M.Post()
     assert_in('TestRole', [r.name for r in c.project.named_roles])
     assert_false(t.is_spam(p))
コード例 #12
0
 def test_new_projects_deleted_projects(self):
     '''Deleted projects should not be visible here'''
     r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
         username='******'))
     count = len(r.html.find('table').findAll('tr'))
     p = M.Project.query.get(shortname='test')
     p.deleted = True
     ThreadLocalORMSession.flush_all()
     r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
         username='******'))
     assert_equal(len(r.html.find('table').findAll('tr')), count - 1)
コード例 #13
0
 def test_new_projects_deleted_projects(self):
     '''Deleted projects should not be visible here'''
     r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
         username='******'))
     count = len(r.html.find('table').findAll('tr'))
     p = M.Project.query.get(shortname='test')
     p.deleted = True
     ThreadLocalORMSession.flush_all()
     r = self.app.get('/nf/admin/new_projects', extra_environ=dict(
         username='******'))
     assert_equal(len(r.html.find('table').findAll('tr')), count - 1)
コード例 #14
0
 def test_create_limit(self, import_tool):
     p = M.Project.query.get(shortname=test_project_with_tracker)
     p.set_tool_data('GitHubTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gh_user_name='spooky',
                   gh_project_name='mulder',
                   mount_point='issues',
                   mount_label='Issues')
     r = self.app.post(self.url + 'create', params, status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #15
0
ファイル: test_code.py プロジェクト: heiths/allura
 def test_create_limit(self, import_tool, extractor):
     extractor.return_value.get_repo_type.return_value = "git"
     project = M.Project.query.get(shortname=test_project_with_repo)
     project.set_tool_data("GoogleRepoImporter", pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gc_project_name="poop", mount_label="mylabel", mount_point="mymount")
     r = self.app.post(
         "/p/{}/admin/ext/import/google-code-repo/create".format(test_project_with_repo), params, status=302
     ).follow()
     self.assertIn("Please wait and try again", r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #16
0
 def test_create_limit(self, import_tool):
     project = M.Project.query.get(shortname='test')
     project.set_tool_data('GoogleCodeTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gc_project_name='test',
                   mount_label='mylabel',
                   mount_point='mymount',
                   )
     r = self.app.post('/p/test/admin/bugs/_importer/create', params,
                       status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #17
0
 def test_create_limit(self, import_tool):
     p = M.Project.query.get(shortname=test_project_with_wiki)
     p.set_tool_data('GitHubWikiImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
         gh_user_name='spooky',
         gh_project_name='mulder',
         mount_point='gh-wiki',
         mount_label='GitHub Wiki')
     r = self.app.post(self.url + 'create', params, status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #18
0
ファイル: test_spam_filter.py プロジェクト: apache/allura
    def test_record_result(self):
        config = {}
        artifact = WM.Page.query.get()
        user = M.User.query.get(username='******')

        SpamFilter(config).record_result(True, artifact, user)
        ThreadLocalORMSession.flush_all()

        results = SpamCheckResult.query.find().all()
        assert_equal(len(results), 1)
        assert_equal(results[0].result, True)
        assert_equal(results[0].user.username, 'test-user')
コード例 #19
0
ファイル: test_wiki.py プロジェクト: vclisunlang/allura
 def test_create_limit(self, import_tool, requests):
     requests.head.return_value.status_code = 200
     p = M.Project.query.get(shortname=test_project_with_wiki)
     p.set_tool_data('GitHubWikiImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gh_user_name='spooky',
                   gh_project_name='mulder',
                   mount_point='gh-wiki',
                   mount_label='GitHub Wiki')
     r = self.app.post(self.url + 'create', params, status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #20
0
 def test_create_limit(self, import_tool, sui):
     project = M.Project.query.get(shortname="test")
     project.set_tool_data("ForgeTrackerImporter", pending=1)
     ThreadLocalORMSession.flush_all()
     params = {
         "tickets_json": webtest.Upload("tickets.json", '{"key": "val"}'),
         "mount_label": "mylabel",
         "mount_point": "mymount",
     }
     r = self.app.post("/p/test/admin/bugs/_importer/create", params, status=302).follow()
     self.assertIn("Please wait and try again", r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #21
0
    def test_record_result(self):
        config = {}
        artifact = WM.Page.query.get()
        user = M.User.query.get(username='******')

        SpamFilter(config).record_result(True, artifact, user)
        ThreadLocalORMSession.flush_all()

        results = SpamCheckResult.query.find().all()
        assert_equal(len(results), 1)
        assert_equal(results[0].result, True)
        assert_equal(results[0].user.username, 'test-user')
コード例 #22
0
def main(start, cnt):
    n = M.Neighborhood.query.get(url_prefix='/p/')
    admin = M.User.by_username('admin1')
    #M.Project.query.remove({'shortname': re.compile('gen-proj-.*')})
    #ThreadLocalORMSession.flush_all()
    for i in range(start, cnt):
        name = 'gen-proj-{}'.format(i)
        project = n.register_project(name, admin)
        if (i-start) > 0 and (i-start) % 100 == 0:
            print 'Created {} projects'.format(i-start)
    print 'Flushing...'
    ThreadLocalORMSession.flush_all()
    print 'Done'
コード例 #23
0
 def test_create_limit(self, import_tool, sui):
     project = M.Project.query.get(shortname='test')
     project.set_tool_data('ForgeTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = {
         'tickets_json': webtest.Upload('tickets.json', '{"key": "val"}'),
         'mount_label': 'mylabel',
         'mount_point': 'mymount',
     }
     r = self.app.post('/p/test/admin/bugs/_importer/create', params,
                       status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #24
0
ファイル: test_tracker.py プロジェクト: abhinavthomas/allura
 def test_create_limit(self, import_tool, requests):
     requests.head.return_value.status_code = 200
     p = M.Project.query.get(shortname=test_project_with_tracker)
     p.set_tool_data('GitHubTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
         gh_user_name='spooky',
         gh_project_name='mulder',
         mount_point='issues',
         mount_label='Issues')
     r = self.app.post(self.url + 'create', params, status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #25
0
 def test_create_limit(self, import_tool, sui):
     project = M.Project.query.get(shortname='test')
     project.set_tool_data('ForgeTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = {
         'tickets_json': webtest.Upload('tickets.json', '{"key": "val"}'),
         'mount_label': 'mylabel',
         'mount_point': 'mymount',
     }
     r = self.app.post('/p/test/admin/bugs/_importer/create',
                       params,
                       status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #26
0
ファイル: test_tracker.py プロジェクト: lym/allura-git
 def test_create_limit(self, import_tool):
     project = M.Project.query.get(shortname='test')
     project.set_tool_data('GoogleCodeTrackerImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
         gc_project_name='test',
         mount_label='mylabel',
         mount_point='mymount',
     )
     r = self.app.post('/p/test/admin/bugs/_importer/create',
                       params,
                       status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #27
0
 def test_create_limit(self, import_tool, extractor):
     extractor.return_value.get_repo_type.return_value = 'git'
     project = M.Project.query.get(shortname=test_project_with_repo)
     project.set_tool_data('GoogleRepoImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(gc_project_name='poop',
             mount_label='mylabel',
             mount_point='mymount',
             )
     r = self.app.post('/p/{}/admin/ext/import/google-code-repo/create'.format(test_project_with_repo),
             params,
             status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #28
0
 def test_create_limit(self, import_tool):
     project = M.Project.query.get(shortname=test_project_with_repo)
     project.set_tool_data('GitHubRepoImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
             gh_user_name='spooky',
             gh_project_name='poop',
             mount_label='mylabel',
             mount_point='mymount',
             )
     r = self.app.post('/p/{}/admin/ext/import/github-repo/create'.format(test_project_with_repo),
             params,
             status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #29
0
 def test_create_limit(self, import_tool):
     project = M.Project.query.get(shortname=test_project_with_repo)
     project.set_tool_data('GitHubRepoImporter', pending=1)
     ThreadLocalORMSession.flush_all()
     params = dict(
         gh_user_name='spooky',
         gh_project_name='poop',
         mount_label='mylabel',
         mount_point='mymount',
     )
     r = self.app.post('/p/{}/admin/ext/import/github-repo/create'.format(
         test_project_with_repo),
                       params,
                       status=302).follow()
     self.assertIn('Please wait and try again', r)
     self.assertEqual(import_tool.post.call_count, 0)
コード例 #30
0
    def test_site_notification_edit_template(self):
        note = M.notification.SiteNotification(active=True,
                                               impressions=0,
                                               content='test1',
                                               user_role='test2',
                                               page_regex='test3',
                                               page_tool_type='test4')
        ThreadLocalORMSession().flush_all()
        r = self.app.get('/nf/admin/site_notifications/{}/edit'.format(note._id))

        assert r
        assert 'checked' in r.form['active'].attrs
        assert r.form['impressions'].value == '0'
        assert r.form['content'].value == 'test1'
        assert r.form['user_role'].value == 'test2'
        assert r.form['page_regex'].value == 'test3'
        assert r.form['page_tool_type'].value == 'test4'

        assert 'Edit Site Notification' in r
        assert 'Active' in r
        assert 'Impressions' in r
        assert 'Content' in r
        assert 'User Role' in r
        assert 'Page Regex' in r
        assert 'Page Type' in r
コード例 #31
0
    def test_site_notifications(self):
        M.notification.SiteNotification(active=True,
                                        impressions=0,
                                        content='test1',
                                        user_role='test2',
                                        page_regex='test3',
                                        page_tool_type='test4')
        ThreadLocalORMSession().flush_all()
        assert M.notification.SiteNotification.query.find().count() == 1

        r = self.app.get('/nf/admin/site_notifications/', extra_environ=dict(
            username='******'))
        table = r.html.find('table')
        headers = table.findAll('th')
        row = table.findAll('td')

        assert headers[0].contents[0] == 'Active'
        assert headers[1].contents[0] == 'Impressions'
        assert headers[2].contents[0] == 'Content'
        assert headers[3].contents[0] == 'User Role'
        assert headers[4].contents[0] == 'Page Regex'
        assert headers[5].contents[0] == 'Page Type'

        assert row[0].contents[0].contents[0] == 'True'
        assert row[1].contents[0].contents[0] == '0'
        assert row[2].contents[0].contents[0] == 'test1'
        assert row[3].contents[0].contents[0] == 'test2'
        assert row[4].contents[0].contents[0] == 'test3'
        assert row[5].contents[0].contents[0] == 'test4'
コード例 #32
0
 def setUp(self):
     super(TestUsersSearch, self).setUp()
     # Create user that matches TEST_HIT id
     _id = ObjectId('540efdf2100d2b1483155d39')
     u = M.User.query.get(_id=_id)
     if not u:
         M.User(_id=_id, username='******')
         ThreadLocalORMSession().flush_all()
コード例 #33
0
    def test_site_notification_delete(self):
        note = M.notification.SiteNotification(active=False,
                                               impressions=0,
                                               content='test')
        ThreadLocalORMSession().flush_all()

        count = M.notification.SiteNotification.query.find().count()

        self.app.post('/nf/admin/site_notifications/{}/delete'.format(note._id))
        assert M.notification.SiteNotification.query.find().count() == count -1
        assert M.notification.SiteNotification.query.get(_id=bson.ObjectId(note._id)) is None
コード例 #34
0
    def test_send_password_reset_link(self, gen_message_id, sendmail):
        user = M.User.by_username('test-user')
        user.set_pref('email_address', '*****@*****.**')
        M.EmailAddress(email='*****@*****.**', confirmed=True, claimed_by_user_id=user._id)
        ThreadLocalORMSession.flush_all()
        with td.audits('Password recovery link sent to: [email protected]', user=True):
            r = self.app.post('/nf/admin/user/send_password_reset_link', params={'username': '******'})
        hash = user.get_tool_data('AuthPasswordReset', 'hash')
        text = '''Your username is test-user

To reset your password on %s, please visit the following URL:

%s/auth/forgotten_password/%s''' % (config['site_name'], config['base_url'], hash)
        sendmail.post.assert_called_once_with(
            toaddr='*****@*****.**',
            fromaddr=config['forgemail.return_path'],
            reply_to=config['forgemail.return_path'],
            subject='Allura Password recovery',
            message_id=gen_message_id(),
            text=text)
コード例 #35
0
 def setUp(self):
     super(TestProjectsSearch, self).setUp()
     # Create project that matches TEST_HIT id
     _id = ObjectId('53ccf6e8100d2b0741746e9f')
     p = M.Project.query.get(_id=_id)
     if not p:
         M.Project(
             _id=_id,
             neighborhood_id=M.Neighborhood.query.get(url_prefix='/u/')._id,
             shortname='test-project',
         )
         ThreadLocalORMSession().flush_all()
コード例 #36
0
ファイル: site_admin.py プロジェクト: githubcodi/allura
 def update(self,
            active=True,
            impressions=0,
            content='',
            user_role=None,
            page_regex=None,
            page_tool_type=None):
     self.note.active = active
     self.note.impressions = impressions
     self.note.content = content
     self.note.user_role = user_role
     self.note.page_regex = page_regex
     self.note.page_tool_type = page_tool_type
     ThreadLocalORMSession().flush_all()
     redirect('..')
コード例 #37
0
ファイル: site_admin.py プロジェクト: githubcodi/allura
 def create(self,
            impressions,
            content,
            user_role,
            page_regex,
            page_tool_type,
            active=False):
     """Post a new note"""
     M.notification.SiteNotification(active=active,
                                     impressions=impressions,
                                     content=content,
                                     user_role=user_role,
                                     page_regex=page_regex,
                                     page_tool_type=page_tool_type)
     ThreadLocalORMSession().flush_all()
     redirect('../site_notifications')
コード例 #38
0
ファイル: session.py プロジェクト: bdeeney/crudite
from ming.datastore import DataStore
from ming.odm import ThreadLocalORMSession

__all__ = ['session']

engine = DataStore(database='flask_tutorial')
session = ThreadLocalORMSession(bind=engine)
コード例 #39
0
ファイル: site_admin.py プロジェクト: xmonader/allura
 def delete(self):
     self.note.delete()
     ThreadLocalORMSession().flush_all()
     redirect(six.ensure_text(request.referer or '/'))
コード例 #40
0
ファイル: site_admin.py プロジェクト: githubcodi/allura
 def delete(self):
     self.note.delete()
     ThreadLocalORMSession().flush_all()
     redirect(request.referer)
コード例 #41
0
ファイル: test_oauth.py プロジェクト: joequant/allura
def setUp():
    setup_basic_test()
    ThreadLocalORMSession.close_all()
    setup_global_objects()
コード例 #42
0
import ming
from ming.datastore import create_datastore
from ming import Session
from ming import schema as s
from ming.odm import ThreadLocalORMSession, FieldProperty, Mapper
from ming.odm.declarative import MappedClass
from datetime import datetime

mainsession = Session()
DBSession = ThreadLocalORMSession(mainsession)

database_setup = False
bind = None


def setup_database():
    global bind, database_setup
    if not database_setup:
        bind = create_datastore('mim:///test')
        mainsession.bind = bind
        ming.odm.Mapper.compile_all()
        database_setup = True


def clear_database():
    global engine, database_setup
    if not database_setup:
        setup_database()


class Thing(MappedClass):
コード例 #43
0
ファイル: test_oauth.py プロジェクト: vclisunlang/allura
def setUp():
    setup_basic_test()
    ThreadLocalORMSession.close_all()
    setup_global_objects()