##// END OF EJS Templates
bump version to 1.1.1
ergo -
r134:b9b70494 1.1.1 stable
parent child Browse files
Show More
@@ -1,77 +1,81 b''
1 import os
1 import os
2 import sys
2 import sys
3 import re
3 import re
4
4
5 from setuptools import setup, find_packages
5 from setuptools import setup, find_packages
6
6
7 here = os.path.abspath(os.path.dirname(__file__))
7 here = os.path.abspath(os.path.dirname(__file__))
8 README = open(os.path.join(here, '..', 'README.md')).read()
8 README = open(os.path.join(here, '..', 'README.md')).read()
9 CHANGES = open(os.path.join(here, 'CHANGELOG.rst')).read()
9 CHANGES = open(os.path.join(here, 'CHANGELOG.rst')).read()
10
10
11 REQUIREMENTS = open(os.path.join(here, 'requirements.txt')).readlines()
11 REQUIREMENTS = open(os.path.join(here, 'requirements.txt')).readlines()
12
12
13 compiled = re.compile('([^=><]*).*')
13 compiled = re.compile('([^=><]*).*')
14
14
15
15
16 def parse_req(req):
16 def parse_req(req):
17 return compiled.search(req).group(1).strip()
17 return compiled.search(req).group(1).strip()
18
18
19
19
20 requires = [_f for _f in map(parse_req, REQUIREMENTS) if _f]
20 requires = [_f for _f in map(parse_req, REQUIREMENTS) if _f]
21
21
22
22
23 def _get_meta_var(name, data, callback_handler=None):
23 def _get_meta_var(name, data, callback_handler=None):
24 import re
24 import re
25 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
25 matches = re.compile(r'(?:%s)\s*=\s*(.*)' % name).search(data)
26 if matches:
26 if matches:
27 if not callable(callback_handler):
27 if not callable(callback_handler):
28 callback_handler = lambda v: v
28 callback_handler = lambda v: v
29
29
30 return callback_handler(eval(matches.groups()[0]))
30 return callback_handler(eval(matches.groups()[0]))
31
31
32 with open(os.path.join(here, 'src', 'appenlight', '__init__.py'), 'r') as _meta:
32 with open(os.path.join(here, 'src', 'appenlight', '__init__.py'), 'r') as _meta:
33 _metadata = _meta.read()
33 _metadata = _meta.read()
34
34
35 with open(os.path.join('src', 'appenlight', 'VERSION')) as _meta_version:
35 with open(os.path.join('src', 'appenlight', 'VERSION')) as _meta_version:
36 __version__ = _meta_version.read().strip()
36 __version__ = _meta_version.read().strip()
37
37
38 __license__ = _get_meta_var('__license__', _metadata)
38 __license__ = _get_meta_var('__license__', _metadata)
39 __author__ = _get_meta_var('__author__', _metadata)
39 __author__ = _get_meta_var('__author__', _metadata)
40 __url__ = _get_meta_var('__url__', _metadata)
40 __url__ = _get_meta_var('__url__', _metadata)
41
41
42 found_packages = find_packages('src')
42 found_packages = find_packages('src')
43 found_packages.append('appenlight.migrations.versions')
43 found_packages.append('appenlight.migrations.versions')
44 setup(name='appenlight',
44 setup(name='appenlight',
45 description='appenlight',
45 description='appenlight',
46 long_description=README + '\n\n' + CHANGES,
46 long_description=README + '\n\n' + CHANGES,
47 classifiers=[
47 classifiers=[
48 "Programming Language :: Python",
48 "Programming Language :: Python",
49 "Framework :: Pylons",
49 "Framework :: Pylons",
50 "Topic :: Internet :: WWW/HTTP",
50 "Topic :: Internet :: WWW/HTTP",
51 "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
51 "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
52 ],
52 ],
53 version=__version__,
53 version=__version__,
54 license=__license__,
54 license=__license__,
55 author=__author__,
55 author=__author__,
56 url=__url__,
56 url=__url__,
57 keywords='web wsgi bfg pylons pyramid',
57 keywords='web wsgi bfg pylons pyramid',
58 package_dir={'': 'src'},
58 package_dir={'': 'src'},
59 packages=found_packages,
59 packages=found_packages,
60 include_package_data=True,
60 include_package_data=True,
61 zip_safe=False,
61 zip_safe=False,
62 test_suite='appenlight',
62 test_suite='appenlight',
63 install_requires=requires,
63 install_requires=requires,
64 extras_require={
65 "dev": ["coverage", "pytest", "pyramid", "tox", "mock", "webtest"],
66 "lint": ["black"],
67 },
64 entry_points={
68 entry_points={
65 'paste.app_factory': [
69 'paste.app_factory': [
66 'main = appenlight:main'
70 'main = appenlight:main'
67 ],
71 ],
68 'console_scripts': [
72 'console_scripts': [
69 'appenlight-cleanup = appenlight.scripts.cleanup:main',
73 'appenlight-cleanup = appenlight.scripts.cleanup:main',
70 'appenlight-initializedb = appenlight.scripts.initialize_db:main',
74 'appenlight-initializedb = appenlight.scripts.initialize_db:main',
71 'appenlight-migratedb = appenlight.scripts.migratedb:main',
75 'appenlight-migratedb = appenlight.scripts.migratedb:main',
72 'appenlight-reindex-elasticsearch = appenlight.scripts.reindex_elasticsearch:main',
76 'appenlight-reindex-elasticsearch = appenlight.scripts.reindex_elasticsearch:main',
73 'appenlight-static = appenlight.scripts.static:main',
77 'appenlight-static = appenlight.scripts.static:main',
74 'appenlight-make-config = appenlight.scripts.make_config:main',
78 'appenlight-make-config = appenlight.scripts.make_config:main',
75 ]
79 ]
76 }
80 }
77 )
81 )
@@ -1,1 +1,1 b''
1 1.1.0
1 1.1.1
@@ -1,222 +1,224 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright 2010 - 2017 RhodeCode GmbH and the AppEnlight project authors
3 # Copyright 2010 - 2017 RhodeCode GmbH and the AppEnlight project authors
4 #
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with 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
7 # You may obtain a copy of the License at
8 #
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
10 #
11 # Unless required by applicable law or agreed to in writing, software
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
15 # limitations under the License.
16
16
17 import datetime
17 import datetime
18 import logging
18 import logging
19 import pyelasticsearch
19 import pyelasticsearch
20 import redis
20 import redis
21 import os
21 import os
22 import pkg_resources
22 from pkg_resources import iter_entry_points
23 from pkg_resources import iter_entry_points
23
24
24 import appenlight.lib.jinja2_filters as jinja2_filters
25 import appenlight.lib.jinja2_filters as jinja2_filters
25 import appenlight.lib.encryption as encryption
26 import appenlight.lib.encryption as encryption
26
27
27 from pyramid.config import PHASE3_CONFIG
28 from pyramid.config import PHASE3_CONFIG
28 from pyramid.authentication import AuthTktAuthenticationPolicy
29 from pyramid.authentication import AuthTktAuthenticationPolicy
29 from pyramid.authorization import ACLAuthorizationPolicy
30 from pyramid.authorization import ACLAuthorizationPolicy
30 from pyramid_mailer.mailer import Mailer
31 from pyramid_mailer.mailer import Mailer
31 from pyramid.renderers import JSON
32 from pyramid.renderers import JSON
32 from pyramid_redis_sessions import session_factory_from_settings
33 from pyramid_redis_sessions import session_factory_from_settings
33 from pyramid.settings import asbool, aslist
34 from pyramid.settings import asbool, aslist
34 from pyramid.security import AllPermissionsList
35 from pyramid.security import AllPermissionsList
35 from pyramid_authstack import AuthenticationStackPolicy
36 from pyramid_authstack import AuthenticationStackPolicy
36 from redlock import Redlock
37 from redlock import Redlock
37 from sqlalchemy import engine_from_config
38 from sqlalchemy import engine_from_config
38
39
39 from appenlight.celery import configure_celery
40 from appenlight.celery import configure_celery
40 from appenlight.lib.configurator import (CythonCompatConfigurator,
41 from appenlight.lib.configurator import (CythonCompatConfigurator,
41 register_appenlight_plugin)
42 register_appenlight_plugin)
42 from appenlight.lib import cache_regions
43 from appenlight.lib import cache_regions
43 from appenlight.lib.ext_json import json
44 from appenlight.lib.ext_json import json
44 from appenlight.security import groupfinder, AuthTokenAuthenticationPolicy
45 from appenlight.security import groupfinder, AuthTokenAuthenticationPolicy
45
46
46 __license__ = 'Apache 2.0'
47 __license__ = 'Apache 2.0'
47 __author__ = 'RhodeCode GmbH'
48 __author__ = 'RhodeCode GmbH'
48 __url__ = 'http://rhodecode.com'
49 __url__ = 'http://rhodecode.com'
50 __version__ = pkg_resources.get_distribution("appenlight").parsed_version
49
51
50 json_renderer = JSON(serializer=json.dumps, indent=4)
52 json_renderer = JSON(serializer=json.dumps, indent=4)
51
53
52 log = logging.getLogger(__name__)
54 log = logging.getLogger(__name__)
53
55
54
56
55 def datetime_adapter(obj, request):
57 def datetime_adapter(obj, request):
56 return obj.isoformat()
58 return obj.isoformat()
57
59
58
60
59 def all_permissions_adapter(obj, request):
61 def all_permissions_adapter(obj, request):
60 return '__all_permissions__'
62 return '__all_permissions__'
61
63
62
64
63 json_renderer.add_adapter(datetime.datetime, datetime_adapter)
65 json_renderer.add_adapter(datetime.datetime, datetime_adapter)
64 json_renderer.add_adapter(AllPermissionsList, all_permissions_adapter)
66 json_renderer.add_adapter(AllPermissionsList, all_permissions_adapter)
65
67
66
68
67 def main(global_config, **settings):
69 def main(global_config, **settings):
68 """ This function returns a Pyramid WSGI application.
70 """ This function returns a Pyramid WSGI application.
69 """
71 """
70 auth_tkt_policy = AuthTktAuthenticationPolicy(
72 auth_tkt_policy = AuthTktAuthenticationPolicy(
71 settings['authtkt.secret'],
73 settings['authtkt.secret'],
72 hashalg='sha512',
74 hashalg='sha512',
73 callback=groupfinder,
75 callback=groupfinder,
74 max_age=2592000,
76 max_age=2592000,
75 secure=asbool(settings.get('authtkt.secure', 'false')))
77 secure=asbool(settings.get('authtkt.secure', 'false')))
76 auth_token_policy = AuthTokenAuthenticationPolicy(
78 auth_token_policy = AuthTokenAuthenticationPolicy(
77 callback=groupfinder
79 callback=groupfinder
78 )
80 )
79 authorization_policy = ACLAuthorizationPolicy()
81 authorization_policy = ACLAuthorizationPolicy()
80 authentication_policy = AuthenticationStackPolicy()
82 authentication_policy = AuthenticationStackPolicy()
81 authentication_policy.add_policy('auth_tkt', auth_tkt_policy)
83 authentication_policy.add_policy('auth_tkt', auth_tkt_policy)
82 authentication_policy.add_policy('auth_token', auth_token_policy)
84 authentication_policy.add_policy('auth_token', auth_token_policy)
83 # set crypto key
85 # set crypto key
84 encryption.ENCRYPTION_SECRET = settings.get('encryption_secret')
86 encryption.ENCRYPTION_SECRET = settings.get('encryption_secret')
85 # import this later so encyption key can be monkeypatched
87 # import this later so encyption key can be monkeypatched
86 from appenlight.models import DBSession, register_datastores
88 from appenlight.models import DBSession, register_datastores
87
89
88 # registration
90 # registration
89 settings['appenlight.disable_registration'] = asbool(
91 settings['appenlight.disable_registration'] = asbool(
90 settings.get('appenlight.disable_registration'))
92 settings.get('appenlight.disable_registration'))
91
93
92 # update config with cometd info
94 # update config with cometd info
93 settings['cometd_servers'] = {'server': settings['cometd.server'],
95 settings['cometd_servers'] = {'server': settings['cometd.server'],
94 'secret': settings['cometd.secret']}
96 'secret': settings['cometd.secret']}
95
97
96 # Create the Pyramid Configurator.
98 # Create the Pyramid Configurator.
97 settings['_mail_url'] = settings['mailing.app_url']
99 settings['_mail_url'] = settings['mailing.app_url']
98 config = CythonCompatConfigurator(
100 config = CythonCompatConfigurator(
99 settings=settings,
101 settings=settings,
100 authentication_policy=authentication_policy,
102 authentication_policy=authentication_policy,
101 authorization_policy=authorization_policy,
103 authorization_policy=authorization_policy,
102 root_factory='appenlight.security.RootFactory',
104 root_factory='appenlight.security.RootFactory',
103 default_permission='view')
105 default_permission='view')
104 # custom registry variables
106 # custom registry variables
105
107
106 # resource type information
108 # resource type information
107 config.registry.resource_types = ['resource', 'application']
109 config.registry.resource_types = ['resource', 'application']
108 # plugin information
110 # plugin information
109 config.registry.appenlight_plugins = {}
111 config.registry.appenlight_plugins = {}
110
112
111 config.set_default_csrf_options(require_csrf=True, header='X-XSRF-TOKEN')
113 config.set_default_csrf_options(require_csrf=True, header='X-XSRF-TOKEN')
112 config.add_view_deriver('appenlight.predicates.csrf_view',
114 config.add_view_deriver('appenlight.predicates.csrf_view',
113 name='csrf_view')
115 name='csrf_view')
114
116
115 # later, when config is available
117 # later, when config is available
116 dogpile_config = {'url': settings['redis.url'],
118 dogpile_config = {'url': settings['redis.url'],
117 "redis_expiration_time": 86400,
119 "redis_expiration_time": 86400,
118 "redis_distributed_lock": True}
120 "redis_distributed_lock": True}
119 cache_regions.regions = cache_regions.CacheRegions(dogpile_config)
121 cache_regions.regions = cache_regions.CacheRegions(dogpile_config)
120 config.registry.cache_regions = cache_regions.regions
122 config.registry.cache_regions = cache_regions.regions
121 engine = engine_from_config(settings, 'sqlalchemy.',
123 engine = engine_from_config(settings, 'sqlalchemy.',
122 json_serializer=json.dumps)
124 json_serializer=json.dumps)
123 DBSession.configure(bind=engine)
125 DBSession.configure(bind=engine)
124
126
125 # json rederer that serializes datetime
127 # json rederer that serializes datetime
126 config.add_renderer('json', json_renderer)
128 config.add_renderer('json', json_renderer)
127 config.set_request_property('appenlight.lib.request.es_conn', 'es_conn')
129 config.set_request_property('appenlight.lib.request.es_conn', 'es_conn')
128 config.set_request_property('appenlight.lib.request.get_user', 'user',
130 config.set_request_property('appenlight.lib.request.get_user', 'user',
129 reify=True)
131 reify=True)
130 config.set_request_property('appenlight.lib.request.get_csrf_token',
132 config.set_request_property('appenlight.lib.request.get_csrf_token',
131 'csrf_token', reify=True)
133 'csrf_token', reify=True)
132 config.set_request_property('appenlight.lib.request.safe_json_body',
134 config.set_request_property('appenlight.lib.request.safe_json_body',
133 'safe_json_body', reify=True)
135 'safe_json_body', reify=True)
134 config.set_request_property('appenlight.lib.request.unsafe_json_body',
136 config.set_request_property('appenlight.lib.request.unsafe_json_body',
135 'unsafe_json_body', reify=True)
137 'unsafe_json_body', reify=True)
136 config.add_request_method('appenlight.lib.request.add_flash_to_headers',
138 config.add_request_method('appenlight.lib.request.add_flash_to_headers',
137 'add_flash_to_headers')
139 'add_flash_to_headers')
138 config.add_request_method('appenlight.lib.request.get_authomatic',
140 config.add_request_method('appenlight.lib.request.get_authomatic',
139 'authomatic', reify=True)
141 'authomatic', reify=True)
140
142
141 config.include('pyramid_redis_sessions')
143 config.include('pyramid_redis_sessions')
142 config.include('pyramid_tm')
144 config.include('pyramid_tm')
143 config.include('pyramid_jinja2')
145 config.include('pyramid_jinja2')
144 config.include('appenlight_client.ext.pyramid_tween')
146 config.include('appenlight_client.ext.pyramid_tween')
145 config.include('ziggurat_foundations.ext.pyramid.sign_in')
147 config.include('ziggurat_foundations.ext.pyramid.sign_in')
146 es_server_list = aslist(settings['elasticsearch.nodes'])
148 es_server_list = aslist(settings['elasticsearch.nodes'])
147 redis_url = settings['redis.url']
149 redis_url = settings['redis.url']
148 log.warning('Elasticsearch server list: {}'.format(es_server_list))
150 log.warning('Elasticsearch server list: {}'.format(es_server_list))
149 log.warning('Redis server: {}'.format(redis_url))
151 log.warning('Redis server: {}'.format(redis_url))
150 config.registry.es_conn = pyelasticsearch.ElasticSearch(es_server_list)
152 config.registry.es_conn = pyelasticsearch.ElasticSearch(es_server_list)
151 config.registry.redis_conn = redis.StrictRedis.from_url(redis_url)
153 config.registry.redis_conn = redis.StrictRedis.from_url(redis_url)
152
154
153 config.registry.redis_lockmgr = Redlock([settings['redis.redlock.url'], ],
155 config.registry.redis_lockmgr = Redlock([settings['redis.redlock.url'], ],
154 retry_count=0, retry_delay=0)
156 retry_count=0, retry_delay=0)
155 # mailer
157 # mailer
156 config.registry.mailer = Mailer.from_settings(settings)
158 config.registry.mailer = Mailer.from_settings(settings)
157
159
158 # Configure sessions
160 # Configure sessions
159 session_factory = session_factory_from_settings(settings)
161 session_factory = session_factory_from_settings(settings)
160 config.set_session_factory(session_factory)
162 config.set_session_factory(session_factory)
161
163
162 # Configure renderers and event subscribers
164 # Configure renderers and event subscribers
163 config.add_jinja2_extension('jinja2.ext.loopcontrols')
165 config.add_jinja2_extension('jinja2.ext.loopcontrols')
164 config.add_jinja2_search_path('appenlight:templates')
166 config.add_jinja2_search_path('appenlight:templates')
165 # event subscribers
167 # event subscribers
166 config.add_subscriber("appenlight.subscribers.application_created",
168 config.add_subscriber("appenlight.subscribers.application_created",
167 "pyramid.events.ApplicationCreated")
169 "pyramid.events.ApplicationCreated")
168 config.add_subscriber("appenlight.subscribers.add_renderer_globals",
170 config.add_subscriber("appenlight.subscribers.add_renderer_globals",
169 "pyramid.events.BeforeRender")
171 "pyramid.events.BeforeRender")
170 config.add_subscriber('appenlight.subscribers.new_request',
172 config.add_subscriber('appenlight.subscribers.new_request',
171 'pyramid.events.NewRequest')
173 'pyramid.events.NewRequest')
172 config.add_view_predicate('context_type_class',
174 config.add_view_predicate('context_type_class',
173 'appenlight.predicates.contextTypeClass')
175 'appenlight.predicates.contextTypeClass')
174
176
175 register_datastores(es_conn=config.registry.es_conn,
177 register_datastores(es_conn=config.registry.es_conn,
176 redis_conn=config.registry.redis_conn,
178 redis_conn=config.registry.redis_conn,
177 redis_lockmgr=config.registry.redis_lockmgr)
179 redis_lockmgr=config.registry.redis_lockmgr)
178
180
179 # base stuff and scan
181 # base stuff and scan
180
182
181 # need to ensure webassets exists otherwise config.override_asset()
183 # need to ensure webassets exists otherwise config.override_asset()
182 # throws exception
184 # throws exception
183 if not os.path.exists(settings['webassets.dir']):
185 if not os.path.exists(settings['webassets.dir']):
184 os.mkdir(settings['webassets.dir'])
186 os.mkdir(settings['webassets.dir'])
185 config.add_static_view(path='appenlight:webassets',
187 config.add_static_view(path='appenlight:webassets',
186 name='static', cache_max_age=3600)
188 name='static', cache_max_age=3600)
187 config.override_asset(to_override='appenlight:webassets/',
189 config.override_asset(to_override='appenlight:webassets/',
188 override_with=settings['webassets.dir'])
190 override_with=settings['webassets.dir'])
189
191
190 config.include('appenlight.views')
192 config.include('appenlight.views')
191 config.include('appenlight.views.admin')
193 config.include('appenlight.views.admin')
192 config.scan(ignore=['appenlight.migrations', 'appenlight.scripts',
194 config.scan(ignore=['appenlight.migrations', 'appenlight.scripts',
193 'appenlight.tests'])
195 'appenlight.tests'])
194
196
195 config.add_directive('register_appenlight_plugin',
197 config.add_directive('register_appenlight_plugin',
196 register_appenlight_plugin)
198 register_appenlight_plugin)
197
199
198 for entry_point in iter_entry_points(group='appenlight.plugins'):
200 for entry_point in iter_entry_points(group='appenlight.plugins'):
199 plugin = entry_point.load()
201 plugin = entry_point.load()
200 plugin.includeme(config)
202 plugin.includeme(config)
201
203
202 # include other appenlight plugins explictly if needed
204 # include other appenlight plugins explictly if needed
203 includes = aslist(settings.get('appenlight.includes', []))
205 includes = aslist(settings.get('appenlight.includes', []))
204 for inc in includes:
206 for inc in includes:
205 config.include(inc)
207 config.include(inc)
206
208
207 # run this after everything registers in configurator
209 # run this after everything registers in configurator
208
210
209 def pre_commit():
211 def pre_commit():
210 jinja_env = config.get_jinja2_environment()
212 jinja_env = config.get_jinja2_environment()
211 jinja_env.filters['tojson'] = json.dumps
213 jinja_env.filters['tojson'] = json.dumps
212 jinja_env.filters['toJSONUnsafe'] = jinja2_filters.toJSONUnsafe
214 jinja_env.filters['toJSONUnsafe'] = jinja2_filters.toJSONUnsafe
213
215
214 config.action(None, pre_commit, order=PHASE3_CONFIG + 999)
216 config.action(None, pre_commit, order=PHASE3_CONFIG + 999)
215
217
216 def wrap_config_celery():
218 def wrap_config_celery():
217 configure_celery(config.registry)
219 configure_celery(config.registry)
218
220
219 config.action(None, wrap_config_celery, order=PHASE3_CONFIG + 999)
221 config.action(None, wrap_config_celery, order=PHASE3_CONFIG + 999)
220
222
221 app = config.make_wsgi_app()
223 app = config.make_wsgi_app()
222 return app
224 return app
General Comments 0
You need to be logged in to leave comments. Login now