Esempio n. 1
0
    def on_file_menu_new(self, widget, data=None):
        msg = "If a database already exists at this connection then creating "\
              "a new database could destroy your data.\n\n<i>Are you sure "\
              "this is what you want to do?</i>"

        if not utils.yes_no_dialog(msg, yes_delay=2):
            return

        #if gui is not None and hasattr(gui, 'insert_menu'):
        submenu = self.insert_menu.get_submenu()
        for c in submenu.get_children():
            submenu.remove(c)
        self.insert_menu.show()
        try:
            db.create()
            pluginmgr.init()
        except Exception, e:
            msg = _('Could not create a new database.\n\n%s') % \
                utils.xml_safe(e)
            tb = utils.xml_safe(traceback.format_exc())
            utils.message_details_dialog(msg, tb, gtk.MESSAGE_ERROR)
            return
Esempio n. 2
0
    def on_file_menu_new(self, widget, data=None):
        msg = "If a database already exists at this connection then creating "\
              "a new database could destroy your data.\n\n<i>Are you sure "\
              "this is what you want to do?</i>"

        if not utils.yes_no_dialog(msg, yes_delay=2):
            return

        #if gui is not None and hasattr(gui, 'insert_menu'):
        submenu = self.insert_menu.get_submenu()
        for c in submenu.get_children():
            submenu.remove(c)
        self.insert_menu.show()
        try:
            db.create()
            pluginmgr.init()
        except Exception, e:
            msg = _('Could not create a new database.\n\n%s') % \
                utils.xml_safe(e)
            tb = utils.xml_safe(traceback.format_exc())
            utils.message_details_dialog(msg, tb, gtk.MESSAGE_ERROR)
            return
Esempio n. 3
0
 def _post_loop():
     gtk.gdk.threads_enter()
     try:
         if isinstance(open_exc, err.DatabaseError):
             msg = _('Would you like to create a new Bauble database at '
                     'the current connection?\n\n<i>Warning: If there is '
                     'already a database at this connection any existing '
                     'data will be destroyed!</i>')
             if utils.yes_no_dialog(msg, yes_delay=2):
                 try:
                     db.create()
                     # db.create() creates all tables registered with
                     # the default metadata so the pluginmgr should be
                     # loaded after the database is created so we don't
                     # inadvertantly create tables from the plugins
                     pluginmgr.init()
                     # set the default connection
                     prefs[conn_default_pref] = conn_name
                 except Exception, e:
                     utils.message_details_dialog(utils.xml_safe(e),
                                                  traceback.format_exc(),
                                                  gtk.MESSAGE_ERROR)
                     logger.error("%s(%s)" % (type(e), e))
         else:
 def _post_loop():
     gtk.gdk.threads_enter()
     try:
         if isinstance(open_exc, err.DatabaseError):
             msg = _('Would you like to create a new Bauble database at ' \
                     'the current connection?\n\n<i>Warning: If there is '\
                     'already a database at this connection any existing '\
                     'data will be destroyed!</i>')
             if utils.yes_no_dialog(msg, yes_delay=2):
                 try:
                     db.create()
                     # db.create() creates all tables registered with
                     # the default metadata so the pluginmgr should be
                     # loaded after the database is created so we don't
                     # inadvertantly create tables from the plugins
                     pluginmgr.init()
                     # set the default connection
                     prefs[conn_default_pref] = conn_name
                 except Exception, e:
                     utils.message_details_dialog(utils.xml_safe_utf8(e),
                                                  traceback.format_exc(),
                                                  gtk.MESSAGE_ERROR)
                     error(e)
         else:
Esempio n. 5
0
        # everything seems to have passed ok so setup the rest of bauble
        if engine is not None:
            bauble.conn_name = name
            self.window.set_title(self.title)
            # TODO: come up with a better way to reset the handler than have
            # to bauble.last_handler = None
            #
            # we have to set last_handler to None since although the
            # view is changing the handler isn't so we might end up
            # using the same instance of a view that could have old
            # settings from the previous handler...
            bauble.last_handler = None
            self.set_default_view()
            self.clear_menu('/ui/MenuBar/insert_menu')
            self.statusbar_clear()
            pluginmgr.init()

    def statusbar_clear(self):
        """
        Call gtk.Statusbar.pop() for each context_id that had previously
        been pushed() onto the the statusbar stack.  This might not clear
        all the messages in the statusbar but it's the best we can do
        without knowing how many messages are in the stack.
        """
        # TODO: to clear everything in the statusbar we would probably
        # have to subclass gtk.Statusbar to keep track of the message
        # ids and context ids so we can properly clear the statusbar.
        for cid in self._cids:
            self.widgets.statusbar.pop(cid)

    def on_help_menu_contents(self, widget, data=None):
Esempio n. 6
0
uri = 'sqlite:///:memory:'


def init_bauble(uri, create=False):
    try:
        db.open(uri, verify=False)
    except Exception, e:
        print >>sys.stderr, e
        #debug e
    if not bauble.db.engine:
        raise BaubleError('not connected to a database')
    prefs.init()
    prefs.testing = True
    pluginmgr.load()
    db.create(create)
    pluginmgr.init(force=True)


def update_gui():
    """
    Flush any GTK Events.  Used for doing GUI testing.
    """
    import gtk
    while gtk.events_pending():
        gtk.main_iteration(block=False)


def check_dupids(filename):
    """
    Return a list of duplicate ids in a glade file
    """
Esempio n. 7
0
        # everything seems to have passed ok so setup the rest of bauble
        if engine is not None:
            bauble.conn_name = name
            self.window.set_title(self.title)
            # TODO: come up with a better way to reset the handler than have
            # to bauble.last_handler = None
            #
            # we have to set last_handler to None since although the
            # view is changing the handler isn't so we might end up
            # using the same instance of a view that could have old
            # settings from the previous handler...
            bauble.last_handler = None
            self.set_default_view()
            self.clear_menu('/ui/MenuBar/insert_menu')
            self.statusbar_clear()
            pluginmgr.init()

    def statusbar_clear(self):
        """
        Call gtk.Statusbar.pop() for each context_id that had previously
        been pushed() onto the the statusbar stack.  This might not clear
        all the messages in the statusbar but it's the best we can do
        without knowing how many messages are in the stack.
        """
        # TODO: to clear everything in the statusbar we would probably
        # have to subclass gtk.Statusbar to keep track of the message
        # ids and context ids so we can properly clear the statusbar.
        for cid in self._cids:
            self.widgets.statusbar.pop(cid)

    def on_help_menu_contents(self, widget, data=None):
Esempio n. 8
0
from sqlalchemy.orm import *
from sqlalchemy.orm.mapper import _mapper_registry
from sqlalchemy.orm.properties import *

import bauble
import bauble.db as db
import bauble.pluginmgr as pluginmgr
from bauble.prefs import prefs
import bauble.view as view

uri = 'sqlite:///:memory:'
db.open(uri, verify=False)
prefs.init()
pluginmgr.load()
db.create(False)
pluginmgr.init(True)

def column_type_str(col):
    print type(col)
    if isinstance(col, sa.String):
        return 'string'
    elif isinstance(col, sa.Unicode):
        return 'unicode'
    elif isinstance(col, sa.Integer):
        return 'integer'
    elif isinstance(col, sa.ForeignKey):
        return 'foreign key(int)'


html_head = '''<html><head>
<style>
Esempio n. 9
0
## for sake of testing, just use sqlite3.
uri = 'sqlite:///:memory:'


def init_bauble(uri, create=False):
    try:
        db.open(uri, verify=False)
    except Exception, e:
        print >> sys.stderr, e
        #debug e
    if not bauble.db.engine:
        raise BaubleError('not connected to a database')
    prefs.init()
    pluginmgr.load()
    db.create(create)
    pluginmgr.init(force=True)


def update_gui():
    """
    Flush any GTK Events.  Used for doing GUI testing.
    """
    import gtk
    while gtk.events_pending():
        gtk.main_iteration(block=False)


def check_dupids(filename):
    """
    Return a list of duplicate ids in a glade file
    """
Esempio n. 10
0
from sqlalchemy.orm import *
from sqlalchemy.orm.mapper import _mapper_registry
from sqlalchemy.orm.properties import *

import bauble
import bauble.db as db
import bauble.pluginmgr as pluginmgr
from bauble.prefs import prefs
import bauble.view as view

uri = 'sqlite:///:memory:'
db.open(uri, verify=False)
prefs.init()
pluginmgr.load()
db.create(False)
pluginmgr.init(True)


def column_type_str(col):
    print type(col)
    if isinstance(col, sa.String):
        return 'string'
    elif isinstance(col, sa.Unicode):
        return 'unicode'
    elif isinstance(col, sa.Integer):
        return 'integer'
    elif isinstance(col, sa.ForeignKey):
        return 'foreign key(int)'


html_head = '''<html><head>