The top level module for Bauble.
bauble.Session is created after the database has been opened with bauble.db.open(). bauble.Session should be used when you need to do ORM based activities on a bauble database. To create a new Session use:
session = bauble.Session()
When you are finished with the session be sure to close the session with session.close(). Failure to close sessions can lead to database deadlocks, particularly when using PostgreSQL based databases.
Call a command handler.
| Parameters: |
|
|---|
Bases: sqlalchemy.ext.declarative.DeclarativeMeta
MapperBase adds the id, _created and _last_updated columns to all tables.
Open a database connection. This function sets bauble.db.engine to the opened engined.
Return bauble.db.engine if successful else returns None and bauble.db.engine remains unchanged.
| Parameters: |
|
|---|
Create new Bauble database at the current connection
| Parameter: | import_defaults (bool) – A flag that is passed to each plugins install() method to indicate where it should import its default data. This is mainly used for testing. The default value is True |
|---|
The connection manager provides a GUI for creating and opening connections. This is the first thing displayed when Bauble starts.
An generic object meant to be extended to provide the view for a GenericModelViewPresenterEditor
Attach an entry completion to a gtk.Entry. The defaults values for this attach_completion assumes the completion popup only shows text and that the text is in the first column of the model.
Return the completion attached to the entry.
NOTE: If you are selecting completions from strings in your model you must set the text_column parameter to the column in the model that holds the strings or else when you select the string from the completions it won’t get set properly in the entry even though you call entry.set_text().
| Parameters: |
|
|---|
Should be caled when after self.start() returns to cleanup undo any changes on the view.
By default all it does is call self.disconnect_all()
| Parameters: |
|
|---|
the presenter of the Model View Presenter Pattern
Add problem_id to self.problems and change the background of widget(s) in problem_widgets.
problem_widgets: either a widget or list of widgets whose background color should change to indicate a problem
| Parameters: |
|
|---|
Dynamically handle completions on a gtk.Entry.
| Parameters: |
|
|---|
completions is requested, returns a list of completions
| Parameter: | on_select – callback for when a value is selected from |
|---|
the list of completions
Revert any changes the presenter might have done to the widgets so that next time the same widgets are open everything will be normal.
By default it only calls self.view.cleanup()
remove problem_id from self.problems and reset the background color of the widget(s) in problem_widgets
| Parameters: |
|
|---|
| Parameters: |
|
|---|
It is best to use this method to set values on the model rather than setting them directly. Derived classes can override this method to take action when the model changes.
GenericModelViewPresenterEditor assume that model is an instance of object mapped to a SQLAlchemy table
The i18n module defines the _() function for creating translatable strings.
Access to standard paths used by Bauble.
Manage plugin registry, loading, initialization and installation. The plugin manager should be started in the following order:
1. load the plugins: search the plugin directory for plugins, populates the plugins dict (happens in load())
2. install the plugins if not in the registry, add properly installed plugins in to the registry (happens in load())
Register command handlers. If a command is a duplicate then it will overwrite the old command of the same name.
@param handler: A class which extends pluginmgr.CommandHandler
Search the plugin path for modules that provide a plugin. If path is a directory then search the directory for plugins. If path is None then use the default plugins path, bauble.plugins.
This method populates the pluginmgr.plugins dict and imports the plugins but doesn’t do any plugin initialization.
| Parameter: | path (str) – the path where to look for the plugins |
|---|
Initialize the plugin manager.
1. Check for and install any plugins in the plugins dict that aren’t in the registry. 2. Call each init() for each plugin the registry in order of dependency 3. Register the command handlers in the plugin’s commands[]
NOTE: This should be called after after Bauble has established a connection to a database with db.open()
| Parameters: |
|
|---|
The bauble.task module allows you to queue up long running tasks. The running tasks still block but allows the GUI to update.
Bases: sqlalchemy.types.TypeDecorator
A database independent Enum type. The value is stored in the database as a Unicode string.
Bases: sqlalchemy.types.TypeDecorator
A Date type that allows Date strings
Bases: sqlalchemy.types.TypeDecorator
A DateTime type that allows strings
A common set of utility functions used throughout Bauble.
Return an iterator with all tables that depend on table. The tables are returned in the order that they depend on each other. For example you know that table[0] does not depend on tables[1].
| Parameters: |
|
|---|
Return a iterable of gtk.TreeIter instances to all occurences of data in model
| Parent: | a gtk.TreeModel or a gtk.TreeModelRow instance |
|---|---|
| Data: | the data to look for |
| Cmp: | the function to call on each row to check if it matches data, default is C{lambda row, data: row[0] == data} |
| Parameter: | obj_with_model – a gtk Widget that has a gtk.TreeModel that can be retrieved with obj_with_mode.get_model |
|---|
Remove the model from the object, deletes all the items in the model, clear the model and then delete the model and set the model on the object to None
find value in combo model and set it as active, else raise ValueError cmp(row, value) is the a function to use for comparison
Note
if more than one value is found in the combo then the first one in the list is set
Returns a gtk.TreeIter that points to first matching value in the combo’s model.
| Parameters: |
|
|---|
Note
if more than one value is found in the combo then the first one in the list is returned
| Parameters: |
|
|---|
Note
any values passed in for widgets that expect a string will call the values __str__ method
Create a message dialog.
| Parameters: |
|
|---|
Returns a gtk.MessageDialog
Create a message dialog with bauble.utils.create_message_dialog() and run and destroy it.
Returns the dialog’s response.
Create and run a yes/no dialog.
Return True if the dialog response equals gtk.RESPONSE_YES
| Parameters: |
|
|---|
Configure a gtk.ComboBox as a text combobox
NOTE: If you pass a cell_data_func that is a method of an object that holds a reference to combo then the object will not be properly garbage collected. To avoid this problem either don’t pass a method of object or make the method static
| Parameters: |
|
|---|
a key getter for sort and sorted function
the sorting is done on return value of obj.__str__() so we can sort objects as well, i don’t know if this will cause problems with unicode
use like: sorted(some_list, key=utils.natsort_key)
If column.sequence is not None or the column is an Integer and column.autoincrement is true then reset the sequence for the next available value for the column...if the column doesn’t have a sequence then do nothing and return
The SQL statements are executed directly from db.engine
| Parameters: |
|
|---|
We don’t do any validation that the format is correct or invalid
| Parameters: |
|
|---|
| Parameter: | col – a string if table.col where col is an enum type |
|---|
return a string with of the values on an enum type join by a comma
Bases: gtk.Notebook
Holds list of expanders with an optional tabbed layout.
The default is to not use tabs. To create the InfoBox with tabs use InfoBox(tabbed=True). When using tabs then you can either add expanders directly to the InfoBoxPage or using InfoBox.add_expander with the page_num argument.
Add an expander to a page.
| Parameters: |
|
|---|
Bases: gtk.ScrolledWindow
A gtk.ScrolledWindow that contains bauble.view.InfoExpander objects.
Add an expander to the list of exanders in this infobox
| Parameter: | expander – the bauble.view.InfoExpander to add to this infobox |
|---|
Returns an expander by the expander’s label name
| Parameter: | label – the name of the expander to return |
|---|
Remove expander from the infobox by the expander’s label bel
| Parameter: | label – the name of th expander to remove |
|---|
Return the expander that was removed from the infobox.
Updates the infobox with values from row
| Parameter: | row – the mapper instance to use to update this infobox, this is passed to each of the infoexpanders in turn |
|---|
Bases: gtk.Expander
an abstract class that is really just a generic expander with a vbox to extend this you just have to implement the update() method
Bases: bauble.view.InfoExpander
The parser for bauble.view.MapperSearch
Interface for adding search strategies to a view.
| Parameter: | text – the search string |
|---|---|
| Param: | the session to use for the search |
Return an iterator that iterates over mapped classes retrieved from the search.
Bases: bauble.view.SearchStrategy
Mapper Search support three types of search expression: 1. value searches: search that are just list of values, e.g. value1, value2, value3, searches all domains and registered columns for values 2. expression searches: searched of the form domain=value, resolves the domain and searches specific columns from the mapping 3. query searchs: searches of the form domain where ident.ident = value, resolve the domain and identifiers and search for value
Returns a ResultSet of database hits for the text search string.
If session=None then the session should be closed after the results have been processed or it is possible that some database backends could cause deadlocks.
A ResultSet represents a set of results returned from a query, it allows you to add results to the set and then iterate over all the results as if they were one set. It will only return objects that are unique between all the results.
Bases: bauble.pluginmgr.View
The SearchView is the main view for Bauble. It manages the search results returned when search strings are entered into the main text entry.
Bases: sqlalchemy.ext.declarative.Base
| Table name: | family |
|---|---|
| Columns: |
|
| Properties: |
|
| Constraints: | The family table has a unique constraint on family/qualifier. |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | family_synonyms |
|---|---|
| Columns: | family_id: synonyms_id: |
| Properties: | synonyms: family: |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | genus |
|---|---|
| Columns: |
author: notes: |
| Properties: | family: synonyms: |
| Contraints: | The combination of genus, author, qualifier and family_id must be unique. |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | genus_synonym |
|---|
Bases: sqlalchemy.ext.declarative.Base
| Table name: | species |
|---|---|
| Columns: |
|
| Properties: | accessions: vernacular_names: default_vernacular_name: synonyms: distribution: |
| Constraints: | The combination of sp, sp_author, hybrid, sp_qual, cv_group, trade_name, infrasp, infrasp_author, infrasp_rank, genus_id |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | species_synonym |
|---|
Bases: sqlalchemy.ext.declarative.Base
| Table name: | vernacular_name |
|---|---|
| Columns: |
|
| Properties: | |
| Constraints: |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | default_vernacular_name |
|---|
DefaultVernacularName is not meant to be instantiated directly. Usually the default vernacular name is set on a species by setting the default_vernacular_name property on Species to a VernacularName instance
| Columns: |
vernacular_name_id: |
|---|---|
| Properties: | |
| Constraints: |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | species_distribution |
|---|---|
| Columns: | |
| Properties: | |
| Constraints: |
Bases: sqlalchemy.ext.declarative.Base
Represents a geography unit.
| Table name: | geography |
|---|---|
| Columns: | name: tdwg_code: iso_code: parent_id: |
| Properties: | children: |
| Constraints: |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | accession |
|---|---|
| Columns: |
|
| Properties: |
|
| Constraints: |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | plant |
|---|---|
| Columns: |
|
| Properties: |
|
| Constraints: | The combination of code and accession_id must be unique. |
Get the plant delimiter from the BaubleMeta table.
The delimiter is cached the first time it is retrieved. To refresh the delimiter from the database call with refresh=True.
Bases: sqlalchemy.ext.declarative.Base
| Table name: | location |
|---|---|
| Columns: | site: description: |
| Relation: | plants: |
Bases: sqlalchemy.ext.declarative.Base
| Table name: | collection |
|---|---|
| Columns: | collector: sqlalchemy.types.Unicode(64) collectors_code: sqlalchemy.types.Unicode(50) date: sqlalchemy.types.Date locale: sqlalchemy.types.UnicodeText(nullable=False) latitude: sqlalchemy.types.Float longitude: sqlalchemy.types.Float gps_datum: sqlalchemy.types.Unicode(32) geo_accy: sqlalchemy.types.Float elevation: sqlalchemy.types.Float elevation_accy: sqlalchemy.types.Float habitat: sqlalchemy.types.UnicodeText geography_id: sqlalchemy.types.Integer(ForeignKey('geography.id')) notes: sqlalchemy.types.UnicodeText accession_id: sqlalchemy.types.Integer(ForeignKey('accession.id'), nullable=False) |
| Properties: |
Also contains an _accession property that was created as a backref from the Accession mapper
| Constraints: |
|---|
Bases: sqlalchemy.ext.declarative.Base
| Table name: | donation |
|---|---|
| Columns: | donor_id: sqlalchemy.types.Integer(ForeignKey('donor.id'), nullable=False) donor_acc: sqlalchemy.types.Unicode(32) notes: sqlalchemy.types.UnicodeText date: bauble.types..Date accession_id: sqlalchemy.types.Integer(ForeignKey('accession.id'), nullable=False) |
| Properties: |
|
The PDF report generator module.
This module takes a list of objects, get all the plants from the objects, converts them to the ABCD XML format, transforms the ABCD data to an XSL formatting stylesheet and uses a XSL-PDF renderer to convert the stylesheet to PDF.