Skip to content

Commit f06a6a6

Browse files
committed
added prep routine for setting schema and geo
1 parent 87ed924 commit f06a6a6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

gtfsdb/model/db.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,22 @@ def factory_from_cmdline(cls, args):
150150
return cls.factory(**kwargs)
151151

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

161-
if self.schema:
162-
orm_cls.set_schema(self.schema)
165+
if schema:
166+
orm_cls.set_schema(schema)
167+
168+
@classmethod
169+
def prep_gtfsdb_model_classes(cls, schema=None, is_geo=False):
170+
for c in cls.get_base_subclasses():
171+
cls.prep_orm_class(c, schema, is_geo)

0 commit comments

Comments
 (0)