1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/65ff8e5a5c21/ Changeset: 65ff8e5a5c21 User: carlfeberhard Date: 2015-01-29 19:30:45+00:00 Summary: Managers: move FilterParsers into base classes Affected #: 3 files
diff -r b2b09f9e85130662ef02ee4ae887530e442f0e37 -r 65ff8e5a5c21d82fd216841af7ab914eaecaf4d6 lib/galaxy/managers/base.py --- a/lib/galaxy/managers/base.py +++ b/lib/galaxy/managers/base.py @@ -807,7 +807,13 @@ """ Set up, extend, or alter `orm_filter_parsers` and `fn_filter_parsers`. """ - pass + self.orm_filter_parsers.update({ + # (prob.) applicable to all models + 'id' : { 'op': ( 'in' ), 'val': self.parse_id_list }, + # dates can be directly passed through the orm into a filter (no need to parse into datetime object) + 'create_time' : { 'op': ( 'le', 'ge' ) }, + 'update_time' : { 'op': ( 'le', 'ge' ) }, + })
def parse_filters( self, filter_tuple_list ): """ @@ -899,6 +905,8 @@ #UNCHANGED_OPS = ( 'like' ) def _convert_op_string_to_fn( self, column, op_string ): """ + Convert the query string filter op shorthand into actual ORM usable + function names, then return the ORM function. """ # correct op_string to usable function key fn_name = op_string @@ -971,7 +979,7 @@ """ Parse a boolean from a string. """ - #Be strict here to remove complexity of options. + # Be strict here to remove complexity of options (but allow already parsed). if bool_string in ( 'True', True ): return True if bool_string in ( 'False', False ): @@ -982,7 +990,9 @@ """ Split `id_list_string` at `sep`. """ - return id_list_string.split( sep ) + #TODO: move id decoding out + id_list = [ self.app.security.decode_id( id_ ) for id_ in id_list_string.split( sep ) ] + return id_list
# ==== Security Mixins @@ -1158,6 +1168,14 @@ return item.deleted
+class DeletableModelFilters( object ): + + def _add_parsers( self ): + self.orm_filter_parsers.update({ + 'deleted' : { 'op': ( 'eq' ), 'val': self.parse_bool } + }) + + class PurgableModelInterface( DeletableModelInterface ): """ A manager interface/mixin for a resource that allows deleting and purging where @@ -1200,3 +1218,12 @@ if new_purged: self.manager.purge( trans, item, flush=False ) return self.purged + + +class PurgableModelFilters( DeletableModelFilters ): + + def _add_parsers( self ): + DeletableModelFilters._add_parsers( self ) + self.orm_filter_parsers.update({ + 'purged' : { 'op': ( 'eq' ), 'val': self.parse_bool } + })
diff -r b2b09f9e85130662ef02ee4ae887530e442f0e37 -r 65ff8e5a5c21d82fd216841af7ab914eaecaf4d6 lib/galaxy/managers/histories.py --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -353,32 +353,17 @@ })
-class HistoryFilters( base.FilterParser ): +class HistoryFilters( sharable.SharableModelFilters, base.PurgableModelFilters ): model_class = model.History
def _add_parsers( self ): super( HistoryFilters, self )._add_parsers() + base.PurgableModelFilters._add_parsers( self ) + self.orm_filter_parsers.update({ - #TODO: these three are (prob.) applicable to all models - 'id' : { 'op': ( 'in' ), 'val': self.parse_id_list }, - # dates can be directly passed through the orm into a filter (no need to parse into datetime object) - 'create_time' : { 'op': ( 'le', 'ge' ) }, - 'update_time' : { 'op': ( 'le', 'ge' ) }, - # history specific 'name' : { 'op': ( 'eq', 'contains', 'like' ) }, 'genome_build' : { 'op': ( 'eq', 'contains', 'like' ) }, - - #TODO: purgable - 'deleted' : { 'op': ( 'eq' ), 'val': self.parse_bool }, - 'purged' : { 'op': ( 'eq' ), 'val': self.parse_bool }, - - #TODO: sharable - 'importable' : { 'op': ( 'eq' ), 'val': self.parse_bool }, - 'published' : { 'op': ( 'eq' ), 'val': self.parse_bool }, - 'slug' : { 'op': ( 'eq', 'contains', 'like' ) }, - # chose by user should prob. only be available for admin? (most often we'll only need trans.user) - #'user' : { 'op': ( 'eq' ), 'val': self.parse_id_list }, })
#TODO: I'm not entirely convinced this (or tags) are a good idea for filters since they involve a/the user
diff -r b2b09f9e85130662ef02ee4ae887530e442f0e37 -r 65ff8e5a5c21d82fd216841af7ab914eaecaf4d6 lib/galaxy/managers/sharable.py --- a/lib/galaxy/managers/sharable.py +++ b/lib/galaxy/managers/sharable.py @@ -416,3 +416,16 @@ # pass
#def deserialize_user_shares(): + + +class SharableModelFilters( base.FilterParser ): + + def _add_parsers( self ): + super( SharableModelFilters, self )._add_parsers() + self.orm_filter_parsers.update({ + 'importable' : { 'op': ( 'eq' ), 'val': self.parse_bool }, + 'published' : { 'op': ( 'eq' ), 'val': self.parse_bool }, + 'slug' : { 'op': ( 'eq', 'contains', 'like' ) }, + # chose by user should prob. only be available for admin? (most often we'll only need trans.user) + #'user' : { 'op': ( 'eq' ), 'val': self.parse_id_list }, + })
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
galaxy-commits@lists.galaxyproject.org