How to use the ming.orm.ormsession.ThreadLocalORMSession function in Ming

To help you get started, we’ve selected a few Ming examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / allura / ForgeTracker / forgetracker / import_support.py View on Github external
field['options'] = ' '.join([field['options'], value])
        elif (field['type'] == 'milestone') and value:
            milestones = field['milestones']
            for milestone in milestones:
                if milestone['name'] == value:
                    if ticket_status in c.app.globals.open_status_names:
                        milestone['complete'] = False
                    break
            else:
                milestone = {'due_date': '',
                             'complete': not ticket_status in c.app.globals.open_status_names,
                             'description': '',
                             'name': value,
                             'old_name': value}
                field['milestones'].append(milestone)
        ThreadLocalORMSession.flush_all()
github apache / allura / Allura / allura / model / session.py View on Github external
doc_session=main_doc_session,
    extensions=[IndexerSessionExtension]
    )
main_explicitflush_orm_session = ThreadLocalORMSession(
    doc_session=main_doc_session,
    extensions=[IndexerSessionExtension, ExplicitFlushOnlySessionExtension]
)
project_orm_session = ThreadLocalORMSession(
    doc_session=project_doc_session,
    extensions=[IndexerSessionExtension]
)
task_orm_session = ThreadLocalORMSession(task_doc_session)
artifact_orm_session = ThreadLocalORMSession(
    doc_session=project_doc_session,
    extensions=[ArtifactSessionExtension])
repository_orm_session = ThreadLocalORMSession(
    doc_session=main_doc_session,
    extensions=[])
github apache / allura / ForgeWiki / forgewiki / scripts / wiki2markdown / loaders.py View on Github external
def load(self):
        try:
            self.project.notifications_disabled = True
            artifact_orm_session._get().skip_mod_date = True
            self.load_pages()
            ThreadLocalORMSession.flush_all()
            log.info('Loading wiki done')
        finally:
            self.project.notifications_disabled = False
            artifact_orm_session._get().skip_mod_date = False
github apache / allura / scripts / migrations / 017-sync-trove-categories.py View on Github external
create_trove_cat((847,80,"realtimetactical","Real Time Tactical","Topic :: Games/Entertainment :: Real Time Tactical"))
    create_trove_cat((848,160,"algol68","ALGOL 68","Programming Language :: ALGOL 68"))
    create_trove_cat((849,92,"groupware","Groupware","Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Groupware"))
    create_trove_cat((850,576,"businesscontinuity","Business Continuity","Topic :: Office/Business :: Enterprise :: Business Continuity"))
    create_trove_cat((852,554,"teiformat","TEI","Topic :: Formats and Protocols :: Data Formats :: TEI"))
    create_trove_cat((853,160,"clarion","Clarion","Programming Language :: Clarion"))
    create_trove_cat((854,576,"sales","Sales","Topic :: Office/Business :: Enterprise :: Sales"))
    create_trove_cat((855,97,"buildingauto","Building Automation","Topic :: Scientific/Engineering :: Building Automation"))
    create_trove_cat((856,129,"businessmodelling","Modelling","Topic :: Office/Business :: Modelling"))
    create_trove_cat((857,150,"routing","Routing","Topic :: System :: Networking :: Routing"))
    create_trove_cat((858,97,"medicalphysics","Medical Physics","Topic :: Scientific/Engineering :: Medical Physics"))
    create_trove_cat((859,71,"edlanguage","Languages","Topic :: Education :: Languages"))
    create_trove_cat((860,97,"molecularmech","Molecular Mechanics","Topic :: Scientific/Engineering :: Molecular Mechanics"))
    create_trove_cat((861,148,"loganalysis","Log Analysis","Topic :: System :: Logging :: Log Analysis"))

    ThreadLocalORMSession.flush_all()
    ThreadLocalORMSession.close_all()
github apache / allura / Allura / allura / command / reactor.py View on Github external
else:
                    # Classmethod or function - don't bind self
                    method(msg.delivery_info['routing_key'], data)
            except: # pragma no cover
                base.log.exception(
                    'Exception audit handling %s: %s',
                    tool_name, method)
                for k,v in self.Supplement(pylons.c, data, msg, 'audit').extraData().items():
                    base.log.error('    %s: %s', k, v)
                if self.options.dry_run: raise
                self.send_error_report(sys.exc_info())
            else:
                ming.orm.ormsession.ThreadLocalORMSession.flush_all()
            finally:
                self.teardown_globals()
                ming.orm.ormsession.ThreadLocalORMSession.close_all()
github apache / allura / ForgeWiki / forgewiki / command / wiki2markdown / attachments.py View on Github external
forums = []
        for discuss in discussions:
            for post in discuss.posts:
                post_id = "%s" % post._id

                if post_id in json_attachments['discuss']:
                    post.text = json_attachments['discuss'][post_id]['text']

        for f in forums:
            for post in f.posts:
                post_id = "%s" % post._id

                if post_id in json_attachments['forums']:
                    post.text = json_attachments['forums'][post_id]['text']

        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()
github apache / allura / ForgeWiki / forgewiki / command / wiki2markdown / history.py View on Github external
hist_id = "%s" % hist._id
                if hist_id in json_history['pages']:
                    hist.data['text'] = json_history['pages'][hist_id]['text']

        if discussion_app is not None:
            discussions = M.Discussion.query.find(app_config_id=discussion_app.config._id).all()
        else:
            discussions = []
        for discuss in discussions:
            for post in discuss.posts:
                for hist in post.history().all():
                    hist_id = "%s" % hist._id
                    if hist_id in json_history['discuss']:
                        hist.data['text'] = json_history['discuss'][hist_id]['text']

        ThreadLocalORMSession.flush_all()
        ThreadLocalORMSession.close_all()
github apache / allura / Allura / allura / model / session.py View on Github external
project_doc_session = Session.by_name('project')
task_doc_session = Session.by_name('task')
main_orm_session = ThreadLocalORMSession(
    doc_session=main_doc_session,
    extensions=[IndexerSessionExtension]
    )
main_explicitflush_orm_session = ThreadLocalORMSession(
    doc_session=main_doc_session,
    extensions=[IndexerSessionExtension, ExplicitFlushOnlySessionExtension]
)
project_orm_session = ThreadLocalORMSession(
    doc_session=project_doc_session,
    extensions=[IndexerSessionExtension]
)
task_orm_session = ThreadLocalORMSession(task_doc_session)
artifact_orm_session = ThreadLocalORMSession(
    doc_session=project_doc_session,
    extensions=[ArtifactSessionExtension])
repository_orm_session = ThreadLocalORMSession(
    doc_session=main_doc_session,
    extensions=[])
github apache / allura / scripts / teamforge-import.py View on Github external
parent=p.parent, timestamp=create_date)
                            p.slug = slug
                            p.full_slug = full_slug
                            if oldest_post is None or oldest_post.timestamp > create_date:
                                oldest_post = p
                            if newest_post is None or newest_post.timestamp < create_date:
                                newest_post = p
                            ThreadLocalORMSession.flush_all()
                    to.num_replies = to_num_replies
                    to.first_post_id = oldest_post._id
                    to.last_post_date = newest_post.timestamp
                    to.mod_date = newest_post.timestamp
                    fo_num_posts += to_num_replies
            fo.num_topics = fo_num_topics
            fo.num_posts = fo_num_posts
            ThreadLocalORMSession.flush_all()