| 1 |
""" |
| 2 |
Basic code for defining objects in the data center: Structures, their |
| 3 |
attributes, fundamental VO conventions. |
| 4 |
""" |
| 5 |
|
| 6 |
#c Copyright 2008-2025, the GAVO project <[email protected]> |
| 7 |
#c |
| 8 |
#c This program is free software, covered by the GNU GPL. See the |
| 9 |
#c COPYING file in the source distribution. |
| 10 |
|
| 11 |
|
| 12 |
# Not checked by pyflakes: API file with gratuitous imports |
| 13 |
|
| 14 |
# This doesn't belong here and it should go away again, but right now, |
| 15 |
# astLib has an issue in the de_DE (and probably other) locales. |
| 16 |
import locale, os |
| 17 |
os.environ["LC_ALL"] = 'C' |
| 18 |
locale.setlocale(locale.LC_ALL, 'C') |
| 19 |
|
| 20 |
from gavo.base import caches |
| 21 |
|
| 22 |
from gavo.base.attrdef import * |
| 23 |
|
| 24 |
from gavo.base.complexattrs import * |
| 25 |
|
| 26 |
from gavo.base.config import( |
| 27 |
get as getConfig, set as setConfig, |
| 28 |
getDBProfile) |
| 29 |
|
| 30 |
from gavo.base.events import EventDispatcher |
| 31 |
|
| 32 |
from gavo.base.macros import (StandardMacroMixin, MacroPackage, |
| 33 |
MacDefAttribute, MacroError, ExpansionDelegator) |
| 34 |
|
| 35 |
ui = EventDispatcher() |
| 36 |
del EventDispatcher |
| 37 |
|
| 38 |
from gavo.utils import Undefined |
| 39 |
|
| 40 |
from gavo.base.common import * |
| 41 |
|
| 42 |
from gavo.base.literals import * |
| 43 |
|
| 44 |
from gavo.base.meta import ( |
| 45 |
MetaSyntaxError, MetaError, MetaCardError, NoMetaKey, |
| 46 |
MetaMixin, ComputedMetaMixin, |
| 47 |
MetaBuilder, |
| 48 |
META_CLASSES_FOR_KEYS, |
| 49 |
getMetaText) |
| 50 |
|
| 51 |
from gavo.base.typedmeta import ( |
| 52 |
InfoItem as MetaInfoItem, |
| 53 |
) |
| 54 |
|
| 55 |
from gavo.base import meta |
| 56 |
# now that typed meta is registered, pull in the fallback metadata |
| 57 |
meta.makeFallbackMeta() |
| 58 |
getGlobalMeta = meta.CONFIG_META.getMeta |
| 59 |
setGlobalMeta = meta.CONFIG_META.setMeta |
| 60 |
|
| 61 |
from gavo.base.metavalidation import MetaValidationError, validateStructure |
| 62 |
|
| 63 |
from gavo.base.observer import ObserverBase, listensTo |
| 64 |
|
| 65 |
from gavo.base.osinter import (getGroupId, makeSharedDir, makeSitePath, |
| 66 |
getBinaryName, makeAbsoluteURL, getVersion, sendMail, |
| 67 |
openDistFile, getPathForDistFile, tryRemoteReload, |
| 68 |
getHTTPBase, getHTTPSBase, getCurrentServerURL, makeLinkForIvoid, |
| 69 |
SERVER_SOFTWARE) |
| 70 |
|
| 71 |
from gavo.base.parsecontext import ( |
| 72 |
IdAttribute, OriginalAttribute, ReferenceAttribute, ParseContext, |
| 73 |
ReferenceListAttribute, resolveId, resolveCrossId, resolveNameBased, |
| 74 |
getTableDefForTable, assertType) |
| 75 |
|
| 76 |
from gavo.base.sqlsupport import (getDBConnection, |
| 77 |
DBError, QueryCanceledError, IntegrityError, |
| 78 |
AdhocQuerier, UnmanagedQuerier, |
| 79 |
getUntrustedConn, |
| 80 |
getTableConn, getAdminConn, getUntrustedConn, |
| 81 |
getWritableTableConn, getWritableAdminConn, getWritableUntrustedConn, |
| 82 |
setDBMeta, getDBMeta, |
| 83 |
getPgVersion, |
| 84 |
NUMERIC_TYPES, ORDERED_TYPES, |
| 85 |
NonBlockingQuery) |
| 86 |
|
| 87 |
from gavo.base.structure import (Structure, ParseableStructure, |
| 88 |
DataContent, makeStruct, RestrictionMixin, buildstructure) |
| 89 |
|
| 90 |
from gavo.base.typesystems import * |
| 91 |
|
| 92 |
from gavo.base.valuemappers import (SerManager, ValueMapperFactoryRegistry, |
| 93 |
VOTNameMaker, registerDefaultMF) |
| 94 |
|
| 95 |
from gavo.base.spectral import getSpecExpr, getSpecConverter, getFilterMap |
| 96 |
|
| 97 |
from gavo.base.sqlmunge import (getSQLForField, getSQLKey, |
| 98 |
joinOperatorExpr) |
| 99 |
|
| 100 |
from gavo.base.unitconv import ( |
| 101 |
computeConversionFactor, parseUnit, computeColumnConversions, |
| 102 |
IncompatibleUnits, BadUnit, |
| 103 |
LIGHT_C, PLANCK_H, BOLTZMANN_K, ELECTRON_CHARGE) |
| 104 |
|
| 105 |
from gavo.base.xmlstruct import (parseFromString, parseFromStream, feedTo, |
| 106 |
structToETree, structToXML) |
| 107 |
|
| 108 |
# preferred MIME type for VOTables we make |
| 109 |
votableType = "application/x-votable+xml" |
| 110 |
|
| 111 |
__version__ = getVersion() |
| 112 |
|
| 113 |
# this flag is set by user.cli if a --debug flag was passed |
| 114 |
DEBUG = False |
| 115 |
# this flag is set by gavo serve if this is a long-running server process |
| 116 |
IS_DACHS_SERVER = False |
| 117 |
# this flag is set by gavo serve if it successfully set up an https |
| 118 |
# connection |
| 119 |
LISTENING_TO_HTTPS = False |