diff --git a/lib/galaxy/model/mapping.py b/lib/galaxy/model/mapping.py index 78662839a2a..642a9cf3511 100644 --- a/lib/galaxy/model/mapping.py +++ b/lib/galaxy/model/mapping.py @@ -3,7 +3,6 @@ Details of how the data model objects are mapped onto the relational database are encapsulated here. """ -import datetime import logging import pkg_resources @@ -16,6 +15,7 @@ from sqlalchemy.orm.collections import attribute_mapped_collection from galaxy import model from galaxy.model.orm.engine_factory import build_engine +from galaxy.model.orm.now import now from galaxy.model.custom_types import JSONType, MetadataType, TrimmedString, UUIDType from galaxy.model.base import ModelMapping from galaxy.security import GalaxyRBACAgent @@ -24,15 +24,6 @@ log = logging.getLogger( __name__ ) metadata = MetaData() -# NOTE REGARDING TIMESTAMPS: -# It is currently difficult to have the timestamps calculated by the -# database in a portable way, so we're doing it in the client. This -# also saves us from needing to postfetch on postgres. HOWEVER: it -# relies on the client's clock being set correctly, so if clustering -# web servers, use a time server to ensure synchronization - -# Return the current time in UTC without any timezone information -now = datetime.datetime.utcnow model.User.table = Table( "galaxy_user", metadata, Column( "id", Integer, primary_key=True), diff --git a/lib/galaxy/model/orm/now.py b/lib/galaxy/model/orm/now.py new file mode 100644 index 00000000000..b6b4de8fa0d --- /dev/null +++ b/lib/galaxy/model/orm/now.py @@ -0,0 +1,13 @@ +from datetime import datetime + +# NOTE REGARDING TIMESTAMPS: +# It is currently difficult to have the timestamps calculated by the +# database in a portable way, so we're doing it in the client. This +# also saves us from needing to postfetch on postgres. HOWEVER: it +# relies on the client's clock being set correctly, so if clustering +# web servers, use a time server to ensure synchronization + +# Return the current time in UTC without any timezone information +now = datetime.utcnow + +__all__ = [now] diff --git a/lib/galaxy/webapps/tool_shed/model/mapping.py b/lib/galaxy/webapps/tool_shed/model/mapping.py index 8dc17d99dac..d66853e2670 100644 --- a/lib/galaxy/webapps/tool_shed/model/mapping.py +++ b/lib/galaxy/webapps/tool_shed/model/mapping.py @@ -5,13 +5,12 @@ are encapsulated here. import logging log = logging.getLogger( __name__ ) -import datetime - from galaxy.webapps.tool_shed.model import * import galaxy.webapps.tool_shed.model from galaxy.model.orm import * from galaxy.model.custom_types import * from galaxy.model.orm.engine_factory import build_engine +from galaxy.model.orm.now import now from galaxy.model.base import ModelMapping import galaxy.webapps.tool_shed.util.shed_statistics as shed_statistics import galaxy.webapps.tool_shed.util.hgweb_config @@ -19,15 +18,6 @@ from galaxy.webapps.tool_shed.security import CommunityRBACAgent metadata = MetaData() -# NOTE REGARDING TIMESTAMPS: -# It is currently difficult to have the timestamps calculated by the -# database in a portable way, so we're doing it in the client. This -# also saves us from needing to postfetch on postgres. HOWEVER: it -# relies on the client's clock being set correctly, so if clustering -# web servers, use a time server to ensure synchronization - -# Return the current time in UTC without any timezone information -now = datetime.datetime.utcnow APIKeys.table = Table( "api_keys", metadata, Column( "id", Integer, primary_key=True ),