3 # Copyright 2007 Google Inc.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 """App Engine Datastore Admin configuration module.
21 Contains global configuration settings for various deployment environments.
23 Configuration values are added as class attributes to the respective
24 environment classes. The environments form a hierarchy of configurations
25 that inherit from one another.
27 At module loading time one module is selected to be the Current module.
28 This is determined by examining the DATACENTER environment variable.
29 See GetConfig for details.
33 New configuration values should be introduced by simply adding constants
34 to the Default class and adding specialized values when needed to override
35 those values specifically for each cluster type. For example, let's say
36 we need to configure the Admin Console URL:
38 class Default(object):
40 ADMIN_CONSOLE_URL = 'https://appengine.google.com'
45 ADMIN_CONSOLE_URL = 'https://127.0.0.1:8000'
50 All values of the Current configuration are imported up to the top level of
51 this module. Access to the configuration values should be done via the module
52 directly. Note that changing configuration values at runtime is NOT supported.
53 It is assumed that values in this configuration module are constants.
59 class Default(object):
60 """Configuration object."""
63 BASE_PATH
= '/_ah/datastore_admin'
64 MAPREDUCE_PATH
= '/_ah/mapreduce'
65 DEFERRED_PATH
= BASE_PATH
+ '/queue/deferred'
66 CLEANUP_MAPREDUCE_STATE
= True
68 DEFAULT_APP_DOMAIN
= 'placeholder.com'
69 GOOGLE_API_HOSTNAME
= 'www.googleapis.com'
70 GOOGLE_API_OAUTH_SCOPE_HOSTNAME
= 'https://www.googleapis.com'
71 GS_API_HOSTNAME
= 'storage.googleapis.com'
72 DATASTORE_ADMIN_API_NAME
= None
73 DATASTORE_ADMIN_API_VERSION
= None
74 DATASTORE_ADMIN_API_VALIDATE_SSL
= True
75 DATASTORE_ADMIN_API_TIMEOUT_SECS
= 30
76 ADMIN_CONSOLE_URL
= 'https://appengine.google.com'
79 def GOOGLE_API_HOST(self
):
80 return 'https://%s' % self
.GOOGLE_API_HOSTNAME
82 def GoogleApiScope(self
, scope_type
):
83 return '%s/%s' % (self
.GOOGLE_API_AUTH
, scope_type
)
86 def GOOGLE_API_AUTH(self
):
87 return '%s/auth' % self
.GOOGLE_API_OAUTH_SCOPE_HOSTNAME
90 def DISCOVERY_URL(self
):
91 return 'https://%s/discovery/v1/apis/{api}/{apiVersion}/rest' % (
92 self
.GOOGLE_API_HOSTNAME
)
94 def GsBucketURL(self
, bucket_name
):
95 return 'https://%s/%s/' % (self
.GS_API_HOSTNAME
, bucket_name
)
99 """Dev-appserver configuration."""
103 """Production cluster configuration."""
104 DEFAULT_APP_DOMAIN
= 'appspot.com'
111 import config_runtime
113 RUNTIME_DATACENTER_TO_CLASS
= config_runtime
.RUNTIME_DATACENTER_TO_CLASS
114 PRODUCTION_CLASS
= config_runtime
.ProdRuntime
116 RUNTIME_DATACENTER_TO_CLASS
= {}
117 PRODUCTION_CLASS
= Prod
121 """Determine configuration class based on the runtime environment.
123 The DATACENTER environment variable is useful for determining which App
124 Engine cluster type this services application is deployed on. All
125 dev-appservers have no DATACENTER variable set. Production does not have any
129 Class of the configuration determined by examining the runtime environment.
131 datacenter
= os
.environ
.get('DATACENTER')
134 for prefix
, config
in RUNTIME_DATACENTER_TO_CLASS
.items():
135 if datacenter
.startswith(prefix
):
137 return PRODUCTION_CLASS
141 """Export public class values to the config module."""
144 for name
in dir(current
):
145 if not name
.startswith('_'):
146 globals()[name
] = getattr(current
, name
)