Esempio n. 1
0
    def run( self, collection_getter, selection_getter ):
        self.options = super(ListActionFromModelFunction, self).run( collection_getter, selection_getter )
        from camelot.admin.form_action import FormActionProgressDialog
        progress = FormActionProgressDialog( unicode(self._name) )
        
        if not self.options and self.Options:
            return self.options

        def create_request( collection_getter, selection_getter, options ):

            def request():
                from sqlalchemy.orm.session import Session
                from camelot.view.remote_signals import get_signal_handler
                sh = get_signal_handler()
                c = list(collection_getter())
                s = list(selection_getter())
                self._model_function( c, s, options )
                to_flush = []
                if self._selection_flush:
                    to_flush = s
                if self._collection_flush:
                    to_flush = c
                for o in to_flush:
                    Session.object_session( o ).flush( [o] )
                    sh.sendEntityUpdate( self, o )

            return request

        post( create_request( collection_getter, selection_getter, self.options ), progress.finished, exception = progress.finished )
        progress.exec_()
Esempio n. 2
0
    def run(self, collection_getter, selection_getter):
        self.options = super(ListActionFromModelFunction,
                             self).run(collection_getter, selection_getter)
        from camelot.admin.form_action import FormActionProgressDialog
        progress = FormActionProgressDialog(unicode(self._name))

        if not self.options and self.Options:
            return self.options

        def create_request(collection_getter, selection_getter, options):
            def request():
                from sqlalchemy.orm.session import Session
                from camelot.view.remote_signals import get_signal_handler
                sh = get_signal_handler()
                c = list(collection_getter())
                s = list(selection_getter())
                self._model_function(c, s, options)
                to_flush = []
                if self._selection_flush:
                    to_flush = s
                if self._collection_flush:
                    to_flush = c
                for o in to_flush:
                    Session.object_session(o).flush([o])
                    sh.sendEntityUpdate(self, o)

            return request

        post(create_request(collection_getter, selection_getter, self.options),
             progress.finished,
             exception=progress.finished)
        progress.exec_()
Esempio n. 3
0
    def run( self, parent = None ):
        from camelot.view.model_thread import post
        options = ApplicationAction.run( self, parent )
        from camelot.admin.form_action import FormActionProgressDialog
        progress = FormActionProgressDialog( unicode(self._name) )
        
        if not options and self.Options:
            return options

        def create_request( options ):

            def request():
                self._model_function( options )

            return request

        post( create_request( self.options ), progress.finished, exception = progress.finished )
        progress.exec_()
Esempio n. 4
0
    def run(self, parent=None):
        from camelot.view.model_thread import post
        options = ApplicationAction.run(self, parent)
        from camelot.admin.form_action import FormActionProgressDialog
        progress = FormActionProgressDialog(unicode(self._name))

        if not options and self.Options:
            return options

        def create_request(options):
            def request():
                self._model_function(options)

            return request

        post(create_request(self.options),
             progress.finished,
             exception=progress.finished)
        progress.exec_()