How to use the kiwi.component.get_utility function in kiwi

To help you get started, we’ve selected a few kiwi 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 stoq / stoq / stoqlib / database / runtime.py View on Github external
def get_current_user(conn):
    """Returns a PersonAdaptToUser instance which represents the current
    logged user on the system
    """
    user = get_utility(ICurrentUser)
    return user.get(user.id, connection=conn)
github stoq / stoq / stoqlib / database / runtime.py View on Github external
def get_current_station(conn):
    """Returns the current station (computer) where the stoqlib applications
    are running on
    """
    station = get_utility(ICurrentBranchStation)
    return station.get(station.id, connection=conn)
github stoq / stoq / stoqlib / domain / payment / operation.py View on Github external
def get_payment_operation_manager():
    """Returns the payment operation manager"""
    pmm = get_utility(IPaymentOperationManager, None)

    if not pmm:
        from stoqlib.lib.payment import PaymentOperationManager
        pmm = PaymentOperationManager()
        provide_utility(IPaymentOperationManager, pmm)

    return pmm
github stoq / stoq / stoqlib / gui / dialogs / crashreportdialog.py View on Github external
def _create_dialog(self):
        app_info = get_utility(IAppInfo, None)

        self._dialog = HIGAlertDialog(parent=self._parent,
                                      flags=Gtk.DialogFlags.MODAL,
                                      type=Gtk.MessageType.WARNING)

        self._dialog.set_details_label(_("Details ..."))
        self._dialog.set_resizable(True)
        primary_fmt = _('We\'r sorry to inform you that an error occurred while '
                        'running %s. Please help us improving Stoq by sending a '
                        'automatically generated report about the incident.\n'
                        'Click on details to see the report text.')
        self._dialog.set_primary(primary_fmt % (app_info.get('name'), ),
                                 bold=False)

        self._create_details()
        self._create_comments()
github stoq / stoq / stoqlib / gui / slaves / paymentslave.py View on Github external
def __init__(self, wizard, parent, store, order, payment_method,
                 outstanding_value=currency(0)):
        BaseEditor.__init__(self, store, order.group)

        self._method = payment_method
        dsm = get_utility(IDomainSlaveMapper)
        slave_class = dsm.get_slave_class(self._method)
        assert slave_class

        self.store.savepoint('before_payment_creation')

        # FIXME: This is a workaround to make the slave_class to ignore the
        #       payments created previously.
        class _InnerSlaveClass(slave_class):
            def get_created_adapted_payments(self):
                return []

        self.slave = _InnerSlaveClass(wizard, parent, self.store, order,
                                      self._method, outstanding_value)
        # FIXME: We need to control how many payments could be created, since
        #       we are ignoring the payments created previously.
        payments = order.group.get_valid_payments().find(
github stoq / stoq / stoq / lib / stoqconfig.py View on Github external
username, password, appname = ret

            if choose_applications:
                self.appname =  appname

            if not username:
                retry_msg = _("specify an username")
                continue

            try:
                self._check_user(username, password)
            except (LoginError, UserProfileError), e:
                # We don't hide the dialog here; it's kept open so the
                # next loop we just can call run() and display the error
                get_utility(ICookieFile).clear()
                retry += 1
                retry_msg = str(e)
            except DatabaseError, e:
                if dialog:
                    dialog.destroy()
                self.abort_mission(str(e))
            else:
                log.info("Authenticated user %s" % username)
                if dialog:
                    dialog.destroy()
                return True

        if dialog:
            dialog.destroy()
        self.abort_mission("Depleted attempts of authentication")
        return False
github stoq / stoq / stoqlib / lib / message.py View on Github external
def yesno(text, default=-1, *verbs):
    sn = get_utility(ISystemNotifier)
    rv = sn.yesno(text, default, *verbs)
    log.info("Yes/No: text='%s' verbs='%r' rv='%r'" %
             (text, verbs, rv))
    return rv
github stoq / stoq / stoq / gui / shell / shellwindow.py View on Github external
def _run_about(self):
        info = get_utility(IAppInfo)
        about = Gtk.AboutDialog()
        about.set_name(info.get("name"))
        about.set_version(info.get("version"))
        about.set_website(stoq.website)
        release_date = stoq.release_date
        about.set_comments(_('Release date: %s') %
                           datetime.datetime(*release_date).strftime('%x'))
        about.set_copyright('Copyright (C) 2005-2012 Async Open Source')

        about.set_logo(render_logo_pixbuf('about'))

        # License

        if locale.getlocale()[0] == 'pt_BR':
            filename = 'COPYING.pt_BR'
        else:
github stoq / stoq / stoqlib / database / runtime.py View on Github external
def initialize_connection():
    # Avoiding circular imports
    global _connection
    assert not _connection, (
        'The connection for this application was already set.')

    try:
        db_settings = get_utility(IDatabaseSettings)
    except NotImplementedError:
        raise StoqlibError('You need to register db settings before calling '
                           'initialize_connection')
    conn = db_settings.get_connection()
    assert conn is not None

    # Stoq applications always use transactions explicitly
    conn.autoCommit = False
    _connection = conn