Skip to content

Commit

Permalink
added prep routine for setting schema and geo
Browse files Browse the repository at this point in the history
  • Loading branch information
fpurcell committed May 23, 2018
1 parent 87ed924 commit f06a6a6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions gtfsdb/model/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,22 @@ def factory_from_cmdline(cls, args):
return cls.factory(**kwargs)

def prep_an_orm_class(self, orm_cls):
self.prep_orm_class(orm_cls, self.schema, self.is_geospatial)

@classmethod
def prep_orm_class(cls, orm_cls, schema=None, is_geospatial=False):
"""
helper method to ready an ORM class (see Base and it's children) according to this Database's settings
:why?: sometimes you might have classes you want as part of a query, but you don't want those classes
available in the Database.classes() or Database.sorted_classes(), since these tables are not being loaded, etc..
"""
if self.is_geospatial and hasattr(orm_cls, 'add_geometry_column'):
if is_geospatial and hasattr(orm_cls, 'add_geometry_column'):
orm_cls.add_geometry_column()

if self.schema:
orm_cls.set_schema(self.schema)
if schema:
orm_cls.set_schema(schema)

@classmethod
def prep_gtfsdb_model_classes(cls, schema=None, is_geo=False):
for c in cls.get_base_subclasses():
cls.prep_orm_class(c, schema, is_geo)

0 comments on commit f06a6a6

Please sign in to comment.