Merge lp:~elachuni/ubuntu-webcatalog/deploy into lp:ubuntu-webcatalog
- deploy
- Merge into trunk
Proposed by
Anthony Lenton
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Łukasz Czyżykowski | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 22 | ||||||||
Proposed branch: | lp:~elachuni/ubuntu-webcatalog/deploy | ||||||||
Merge into: | lp:ubuntu-webcatalog | ||||||||
Diff against target: |
749 lines (+437/-167) 13 files modified
.bzrignore (+3/-0) debian/control (+8/-1) django_project/config/main.cfg (+98/-0) django_project/settings.py (+24/-156) django_project/urls.py (+8/-0) fabtasks/bootstrap.py (+32/-0) fabtasks/upgrade_from_package.py (+4/-3) requirements.txt (+8/-3) setup.py (+20/-4) src/webcatalog/context_processors.py (+26/-0) src/webcatalog/middleware/exception.py (+127/-0) src/webcatalog/schema.py (+61/-0) src/webcatalog/wsgi.py (+18/-0) |
||||||||
To merge this branch: | bzr merge lp:~elachuni/ubuntu-webcatalog/deploy | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Canonical ISD hackers | Pending | ||
Review via email: mp+65276@code.launchpad.net |
Commit message
Added several infrastructure modules and classes.
Description of the change
Overview
========
This branch adds standard ISD modules and classes, prepping for a deployment.
Details
=======
Integration for the following was added in this branch:
- (django-)configglue
- django-preflight
- django-adminaudit
- django-pgtools
- Google analytics
- django_openid_auth (for admin authentication)
- wsgi-oops
To post a comment you must log in.
Revision history for this message
Łukasz Czyżykowski (lukasz-czyzykowski) wrote : | # |
Revision history for this message
ISD Branch Mangler (isd-branches-mangler) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
- 22. By Anthony Lenton
-
[r=lukasz-
czyzykowski] Added several infrastructure modules and classes.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2011-06-07 17:27:12 +0000 | |||
3 | +++ .bzrignore 2011-06-21 11:33:32 +0000 | |||
4 | @@ -1,8 +1,11 @@ | |||
5 | 1 | webcatalog.db | 1 | webcatalog.db |
6 | 2 | src/ubuntu_webcatalog.egg-info/ | 2 | src/ubuntu_webcatalog.egg-info/ |
7 | 3 | virtualenv/ | 3 | virtualenv/ |
8 | 4 | django_project/adminaudit | ||
9 | 5 | django_project/django_openid_auth | ||
10 | 4 | django_project/local_settings.py | 6 | django_project/local_settings.py |
11 | 5 | django_project/static/ | 7 | django_project/static/ |
12 | 6 | django_project/media_root_dev/* | 8 | django_project/media_root_dev/* |
13 | 7 | .backup | 9 | .backup |
14 | 8 | tags | 10 | tags |
15 | 11 | branches/ | ||
16 | 9 | 12 | ||
17 | === modified file 'debian/control' | |||
18 | --- debian/control 2011-06-17 15:33:40 +0000 | |||
19 | +++ debian/control 2011-06-21 11:33:32 +0000 | |||
20 | @@ -18,6 +18,13 @@ | |||
21 | 18 | python-django (>> 1.2.4), | 18 | python-django (>> 1.2.4), |
22 | 19 | python-imaging, | 19 | python-imaging, |
23 | 20 | python-configglue (>> 0.9.1), | 20 | python-configglue (>> 0.9.1), |
25 | 21 | python-django-configglue (>> 0.3) | 21 | python-django-configglue (>> 0.3), |
26 | 22 | python-django-preflight, | ||
27 | 23 | python-django-adminaudit, | ||
28 | 24 | python-django-pgtools, | ||
29 | 25 | python-django-south, | ||
30 | 26 | python-django-openid-auth, | ||
31 | 27 | python-wsgi-oops, | ||
32 | 28 | python-apt | ||
33 | 22 | Description: Ubuntu Web Catalog | 29 | Description: Ubuntu Web Catalog |
34 | 23 | Providing web access to the Ubuntu Software Center. | 30 | Providing web access to the Ubuntu Software Center. |
35 | 24 | 31 | ||
36 | === added directory 'django_project/config' | |||
37 | === added file 'django_project/config/main.cfg' | |||
38 | --- django_project/config/main.cfg 1970-01-01 00:00:00 +0000 | |||
39 | +++ django_project/config/main.cfg 2011-06-21 11:33:32 +0000 | |||
40 | @@ -0,0 +1,98 @@ | |||
41 | 1 | [__noschema__] | ||
42 | 2 | hostname = webcatalog.staging.ubuntu.com | ||
43 | 3 | |||
44 | 4 | [django] | ||
45 | 5 | authentication_backends = django_openid_auth.auth.OpenIDBackend | ||
46 | 6 | django.contrib.auth.backends.ModelBackend | ||
47 | 7 | |||
48 | 8 | databases = django_databases | ||
49 | 9 | logging = django_logging | ||
50 | 10 | |||
51 | 11 | debug = true | ||
52 | 12 | media_root = django_project/media_root_dev/ | ||
53 | 13 | |||
54 | 14 | installed_apps = django.contrib.auth | ||
55 | 15 | django.contrib.contenttypes | ||
56 | 16 | django.contrib.sessions | ||
57 | 17 | django.contrib.sites | ||
58 | 18 | django.contrib.messages | ||
59 | 19 | django.contrib.staticfiles | ||
60 | 20 | django.contrib.markup | ||
61 | 21 | adminaudit | ||
62 | 22 | django.contrib.admin | ||
63 | 23 | django_openid_auth | ||
64 | 24 | django_configglue | ||
65 | 25 | webcatalog | ||
66 | 26 | south | ||
67 | 27 | preflight | ||
68 | 28 | pgtools | ||
69 | 29 | login_url = /openid/login/ | ||
70 | 30 | managers = %(admins)s | ||
71 | 31 | middleware_classes = django.middleware.common.CommonMiddleware | ||
72 | 32 | django.contrib.sessions.middleware.SessionMiddleware | ||
73 | 33 | django.middleware.csrf.CsrfViewMiddleware | ||
74 | 34 | django.contrib.auth.middleware.AuthenticationMiddleware | ||
75 | 35 | django.contrib.messages.middleware.MessageMiddleware | ||
76 | 36 | webcatalog.middleware.exception.LogExceptionMiddleware | ||
77 | 37 | fixture_dirs = | ||
78 | 38 | |||
79 | 39 | secret_key = eepu9Av5ixage9ahhodovahfaiFoorodahf6keip3eichaeW9f | ||
80 | 40 | template_debug = %(debug)s | ||
81 | 41 | time_zone = Europe/London | ||
82 | 42 | media_url = /site_media/ | ||
83 | 43 | use_etags = true | ||
84 | 44 | |||
85 | 45 | template_context_processors = django.contrib.auth.context_processors.auth | ||
86 | 46 | django.core.context_processors.debug | ||
87 | 47 | django.core.context_processors.i18n | ||
88 | 48 | django.core.context_processors.media | ||
89 | 49 | django.core.context_processors.static | ||
90 | 50 | django.contrib.messages.context_processors.messages | ||
91 | 51 | webcatalog.context_processors.google_analytics_id | ||
92 | 52 | |||
93 | 53 | template_dirs = django_project/templates/ | ||
94 | 54 | static_root = ./django_project/static/ | ||
95 | 55 | static_url = /assets/ | ||
96 | 56 | |||
97 | 57 | # Django-1.1 backwards compatibility | ||
98 | 58 | database_engine = sqlite3 | ||
99 | 59 | database_name = webcatalog.db | ||
100 | 60 | |||
101 | 61 | |||
102 | 62 | [django_databases] | ||
103 | 63 | default = default_database | ||
104 | 64 | |||
105 | 65 | [default_database] | ||
106 | 66 | engine = sqlite3 | ||
107 | 67 | name = webcatalog.db | ||
108 | 68 | |||
109 | 69 | [django_logging] | ||
110 | 70 | loggers = django_loggers | ||
111 | 71 | version = 1 | ||
112 | 72 | disable_existing_loggers = False | ||
113 | 73 | |||
114 | 74 | [django_loggers] | ||
115 | 75 | |||
116 | 76 | [openid] | ||
117 | 77 | openid_sso_server_url = https://login.staging.ubuntu.com | ||
118 | 78 | openid_create_users = true | ||
119 | 79 | openid_update_details_from_sreg = true | ||
120 | 80 | openid_launchpad_teams_mapping = openid_team_mapping | ||
121 | 81 | |||
122 | 82 | |||
123 | 83 | [openid_team_mapping] | ||
124 | 84 | # Structure here is: LP Team = Django Group | ||
125 | 85 | canonical-isd-hackers = admin | ||
126 | 86 | canonical-losas = admin | ||
127 | 87 | |||
128 | 88 | [oops] | ||
129 | 89 | oops_dir = /srv/%(hostname)s/staging-logs/www-oops | ||
130 | 90 | |||
131 | 91 | [webcatalog] | ||
132 | 92 | serve_site_media = True | ||
133 | 93 | sca_api_url = https://sc.staging.ubuntu.com/api/2.0/ | ||
134 | 94 | disk_apt_cache_location = /tmp/webcat_cache | ||
135 | 95 | |||
136 | 96 | [google] | ||
137 | 97 | google_analytics_id = UA-1018242-24 | ||
138 | 98 | |||
139 | 0 | 99 | ||
140 | === modified file 'django_project/settings.py' | |||
141 | --- django_project/settings.py 2011-06-17 17:48:07 +0000 | |||
142 | +++ django_project/settings.py 2011-06-21 11:33:32 +0000 | |||
143 | @@ -1,156 +1,24 @@ | |||
300 | 1 | # Django settings for django_project project. | 1 | from __future__ import absolute_import |
301 | 2 | 2 | ||
302 | 3 | DEBUG = True | 3 | import os.path |
303 | 4 | TEMPLATE_DEBUG = DEBUG | 4 | |
304 | 5 | 5 | from configglue.pyschema import SchemaConfigParser | |
305 | 6 | ADMINS = ( | 6 | from django_configglue.utils import update_settings |
306 | 7 | # ('Your Name', 'your_email@example.com'), | 7 | |
307 | 8 | ) | 8 | from webcatalog.schema import WebCatalogSchema |
308 | 9 | 9 | ||
309 | 10 | MANAGERS = ADMINS | 10 | |
310 | 11 | 11 | # get absolute path for config files | |
311 | 12 | DATABASES = { | 12 | current_dir = os.path.dirname(os.path.abspath(__file__)) |
312 | 13 | 'default': { | 13 | config_files = map(lambda x: os.path.join(current_dir, x), |
313 | 14 | 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. | 14 | ['config/main.cfg', '../../local_config/local.cfg', |
314 | 15 | 'NAME': 'webcatalog.db', # Or path to database file if using sqlite3. | 15 | 'local.cfg']) |
315 | 16 | 'USER': '', # Not used with sqlite3. | 16 | |
316 | 17 | 'PASSWORD': '', # Not used with sqlite3. | 17 | # parse config files |
317 | 18 | 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. | 18 | parser = SchemaConfigParser(WebCatalogSchema()) |
318 | 19 | 'PORT': '', # Set to empty string for default. Not used with sqlite3. | 19 | parser.read(config_files) |
319 | 20 | } | 20 | update_settings(parser, locals()) |
320 | 21 | } | 21 | |
321 | 22 | 22 | # keep parser reference | |
322 | 23 | # Local time zone for this installation. Choices can be found here: | 23 | __CONFIGGLUE_PARSER__ = parser |
323 | 24 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name | 24 | |
168 | 25 | # although not all choices may be available on all operating systems. | ||
169 | 26 | # On Unix systems, a value of None will cause Django to use the same | ||
170 | 27 | # timezone as the operating system. | ||
171 | 28 | # If running in a Windows environment this must be set to the same as your | ||
172 | 29 | # system time zone. | ||
173 | 30 | TIME_ZONE = 'America/Chicago' | ||
174 | 31 | |||
175 | 32 | # Language code for this installation. All choices can be found here: | ||
176 | 33 | # http://www.i18nguy.com/unicode/language-identifiers.html | ||
177 | 34 | LANGUAGE_CODE = 'en-us' | ||
178 | 35 | |||
179 | 36 | SITE_ID = 1 | ||
180 | 37 | |||
181 | 38 | # If you set this to False, Django will make some optimizations so as not | ||
182 | 39 | # to load the internationalization machinery. | ||
183 | 40 | USE_I18N = True | ||
184 | 41 | |||
185 | 42 | # If you set this to False, Django will not format dates, numbers and | ||
186 | 43 | # calendars according to the current locale | ||
187 | 44 | USE_L10N = True | ||
188 | 45 | |||
189 | 46 | # Absolute filesystem path to the directory that will hold user-uploaded files. | ||
190 | 47 | # Example: "/home/media/media.lawrence.com/media/" | ||
191 | 48 | MEDIA_ROOT = './django_project/media_root_dev/' | ||
192 | 49 | |||
193 | 50 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a | ||
194 | 51 | # trailing slash. | ||
195 | 52 | # Examples: "http://media.lawrence.com/media/", "http://example.com/media/" | ||
196 | 53 | MEDIA_URL = '/site_media/' | ||
197 | 54 | |||
198 | 55 | # Absolute path to the directory static files should be collected to. | ||
199 | 56 | # Don't put anything in this directory yourself; store your static files | ||
200 | 57 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. | ||
201 | 58 | # Example: "/home/media/media.lawrence.com/static/" | ||
202 | 59 | STATIC_ROOT = './django_project/static/' | ||
203 | 60 | |||
204 | 61 | # URL prefix for static files. | ||
205 | 62 | # Example: "http://media.lawrence.com/static/" | ||
206 | 63 | STATIC_URL = '/assets/' | ||
207 | 64 | |||
208 | 65 | # URL prefix for admin static files -- CSS, JavaScript and images. | ||
209 | 66 | # Make sure to use a trailing slash. | ||
210 | 67 | # Examples: "http://foo.com/static/admin/", "/static/admin/". | ||
211 | 68 | ADMIN_MEDIA_PREFIX = '/assets/admin/' | ||
212 | 69 | |||
213 | 70 | # Additional locations of static files | ||
214 | 71 | STATICFILES_DIRS = ( | ||
215 | 72 | # Put strings here, like "/home/html/static" or "C:/www/django/static". | ||
216 | 73 | # Always use forward slashes, even on Windows. | ||
217 | 74 | # Don't forget to use absolute paths, not relative paths. | ||
218 | 75 | ) | ||
219 | 76 | |||
220 | 77 | # List of finder classes that know how to find static files in | ||
221 | 78 | # various locations. | ||
222 | 79 | STATICFILES_FINDERS = ( | ||
223 | 80 | 'django.contrib.staticfiles.finders.FileSystemFinder', | ||
224 | 81 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', | ||
225 | 82 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', | ||
226 | 83 | ) | ||
227 | 84 | |||
228 | 85 | # Make this unique, and don't share it with anybody. | ||
229 | 86 | SECRET_KEY = '5t7w7uzf&_^goikwn)!g3lmn07gw7x&193uvs#irw4h=1#*%%-' | ||
230 | 87 | |||
231 | 88 | # List of callables that know how to import templates from various sources. | ||
232 | 89 | TEMPLATE_LOADERS = ( | ||
233 | 90 | 'django.template.loaders.filesystem.Loader', | ||
234 | 91 | 'django.template.loaders.app_directories.Loader', | ||
235 | 92 | # 'django.template.loaders.eggs.Loader', | ||
236 | 93 | ) | ||
237 | 94 | |||
238 | 95 | MIDDLEWARE_CLASSES = ( | ||
239 | 96 | 'django.middleware.common.CommonMiddleware', | ||
240 | 97 | 'django.contrib.sessions.middleware.SessionMiddleware', | ||
241 | 98 | 'django.middleware.csrf.CsrfViewMiddleware', | ||
242 | 99 | 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
243 | 100 | 'django.contrib.messages.middleware.MessageMiddleware', | ||
244 | 101 | ) | ||
245 | 102 | |||
246 | 103 | ROOT_URLCONF = 'django_project.urls' | ||
247 | 104 | |||
248 | 105 | TEMPLATE_DIRS = ( | ||
249 | 106 | './django_project/templates', | ||
250 | 107 | ) | ||
251 | 108 | |||
252 | 109 | INSTALLED_APPS = ( | ||
253 | 110 | 'django.contrib.auth', | ||
254 | 111 | 'django.contrib.contenttypes', | ||
255 | 112 | 'django.contrib.sessions', | ||
256 | 113 | 'django.contrib.sites', | ||
257 | 114 | 'django.contrib.messages', | ||
258 | 115 | 'django.contrib.staticfiles', | ||
259 | 116 | 'django.contrib.admin', | ||
260 | 117 | 'south', | ||
261 | 118 | 'webcatalog', | ||
262 | 119 | ) | ||
263 | 120 | |||
264 | 121 | # A sample logging configuration. The only tangible logging | ||
265 | 122 | # performed by this configuration is to send an email to | ||
266 | 123 | # the site admins on every HTTP 500 error. | ||
267 | 124 | # See http://docs.djangoproject.com/en/dev/topics/logging for | ||
268 | 125 | # more details on how to customize your logging configuration. | ||
269 | 126 | LOGGING = { | ||
270 | 127 | 'version': 1, | ||
271 | 128 | 'disable_existing_loggers': False, | ||
272 | 129 | 'handlers': { | ||
273 | 130 | 'mail_admins': { | ||
274 | 131 | 'level': 'ERROR', | ||
275 | 132 | 'class': 'django.utils.log.AdminEmailHandler' | ||
276 | 133 | } | ||
277 | 134 | }, | ||
278 | 135 | 'loggers': { | ||
279 | 136 | 'django.request': { | ||
280 | 137 | 'handlers': ['mail_admins'], | ||
281 | 138 | 'level': 'ERROR', | ||
282 | 139 | 'propagate': True, | ||
283 | 140 | }, | ||
284 | 141 | } | ||
285 | 142 | } | ||
286 | 143 | |||
287 | 144 | ######################## | ||
288 | 145 | # Ubuntu Web Catalog specific settings: | ||
289 | 146 | ######################## | ||
290 | 147 | |||
291 | 148 | # Strictly for use in our dev environment: | ||
292 | 149 | SERVE_SITE_MEDIA = True | ||
293 | 150 | SCA_API_URL = 'https://sc.staging.ubuntu.com/api/2.0/' | ||
294 | 151 | DISK_APT_CACHE_LOCATION = '/tmp/webcat_cache' | ||
295 | 152 | |||
296 | 153 | try: | ||
297 | 154 | from local_settings import * | ||
298 | 155 | except ImportError: | ||
299 | 156 | pass | ||
324 | 157 | 25 | ||
325 | === removed directory 'django_project/templates' | |||
326 | === modified file 'django_project/urls.py' | |||
327 | --- django_project/urls.py 2011-05-06 15:03:41 +0000 | |||
328 | +++ django_project/urls.py 2011-06-21 11:33:32 +0000 | |||
329 | @@ -15,15 +15,23 @@ | |||
330 | 15 | # You should have received a copy of the GNU Affero General Public License | 15 | # You should have received a copy of the GNU Affero General Public License |
331 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
332 | 17 | 17 | ||
333 | 18 | import preflight | ||
334 | 19 | import adminaudit | ||
335 | 18 | from django.conf.urls.defaults import patterns, include, url | 20 | from django.conf.urls.defaults import patterns, include, url |
336 | 19 | from django.conf import settings | 21 | from django.conf import settings |
337 | 20 | from django.contrib import admin | 22 | from django.contrib import admin |
338 | 23 | from django.views.generic.simple import redirect_to | ||
339 | 21 | 24 | ||
340 | 22 | admin.autodiscover() | 25 | admin.autodiscover() |
341 | 26 | preflight.autodiscover() | ||
342 | 27 | adminaudit.audit_install() | ||
343 | 23 | 28 | ||
344 | 24 | urlpatterns = patterns('', | 29 | urlpatterns = patterns('', |
345 | 25 | url(r'^cat/', include('webcatalog.urls')), | 30 | url(r'^cat/', include('webcatalog.urls')), |
346 | 26 | url(r'^admin/', include(admin.site.urls)), | 31 | url(r'^admin/', include(admin.site.urls)), |
347 | 32 | (r'^preflight/$', include('preflight.urls')), | ||
348 | 33 | url(r'^$', redirect_to, {'url': '/cat/'}), | ||
349 | 34 | |||
350 | 27 | ) | 35 | ) |
351 | 28 | 36 | ||
352 | 29 | if settings.SERVE_SITE_MEDIA: | 37 | if settings.SERVE_SITE_MEDIA: |
353 | 30 | 38 | ||
354 | === modified file 'fabtasks/bootstrap.py' | |||
355 | --- fabtasks/bootstrap.py 2011-05-06 21:00:11 +0000 | |||
356 | +++ fabtasks/bootstrap.py 2011-06-21 11:33:32 +0000 | |||
357 | @@ -52,13 +52,45 @@ | |||
358 | 52 | if not os.path.exists(link_name): | 52 | if not os.path.exists(link_name): |
359 | 53 | os.symlink(os.path.abspath(source), link_name) | 53 | os.symlink(os.path.abspath(source), link_name) |
360 | 54 | 54 | ||
361 | 55 | def _get_or_pull_bzr_branch(repo, name, revision=None): | ||
362 | 56 | if revision is None: | ||
363 | 57 | revision = "" | ||
364 | 58 | else: | ||
365 | 59 | revision = "--revision={0}".format(revision) | ||
366 | 60 | if not os.path.exists("branches"): | ||
367 | 61 | os.mkdir('branches') | ||
368 | 62 | branch_path = os.path.join("branches", name) | ||
369 | 63 | if os.path.exists(branch_path): | ||
370 | 64 | local("rm -r {0}".format(branch_path)) | ||
371 | 65 | local("bzr branch {0} {1} {2}".format( | ||
372 | 66 | revision, repo, branch_path), capture=False) | ||
373 | 67 | |||
374 | 68 | def pull_required_branches(): | ||
375 | 69 | _get_or_pull_bzr_branch( | ||
376 | 70 | "lp:django-adminaudit", | ||
377 | 71 | "django-adminaudit") | ||
378 | 72 | _symlink( | ||
379 | 73 | "branches/django-adminaudit/adminaudit", | ||
380 | 74 | "django_project/adminaudit") | ||
381 | 75 | _get_or_pull_bzr_branch( | ||
382 | 76 | "lp:~django-openid-auth/django-openid-auth/trunk", | ||
383 | 77 | "django-openid-auth", | ||
384 | 78 | revision=79) | ||
385 | 79 | _symlink( | ||
386 | 80 | "branches/django-openid-auth/django_openid_auth", | ||
387 | 81 | "django_project/django_openid_auth") | ||
388 | 55 | 82 | ||
389 | 56 | def bootstrap(): | 83 | def bootstrap(): |
390 | 57 | virtualenv_create() | 84 | virtualenv_create() |
391 | 58 | install_requirements() | 85 | install_requirements() |
392 | 86 | pull_required_branches() | ||
393 | 59 | 87 | ||
394 | 60 | 88 | ||
395 | 61 | def clean(): | 89 | def clean(): |
396 | 90 | local("rm -rf branches/") | ||
397 | 62 | local("rm -rf virtualenv/") | 91 | local("rm -rf virtualenv/") |
398 | 63 | local("rm -rf src/ubuntu_webcatalog.egg-info") | 92 | local("rm -rf src/ubuntu_webcatalog.egg-info") |
399 | 64 | local("rm -f webcatalog.db") | 93 | local("rm -f webcatalog.db") |
400 | 94 | links = ("adminaudit", "django_openid_auth") | ||
401 | 95 | for link in links: | ||
402 | 96 | local("rm -f django_project/{0}".format(link)) | ||
403 | 65 | 97 | ||
404 | === modified file 'fabtasks/upgrade_from_package.py' | |||
405 | --- fabtasks/upgrade_from_package.py 2011-04-05 02:19:30 +0000 | |||
406 | +++ fabtasks/upgrade_from_package.py 2011-06-21 11:33:32 +0000 | |||
407 | @@ -69,7 +69,7 @@ | |||
408 | 69 | recipe = dedent("""\ | 69 | recipe = dedent("""\ |
409 | 70 | # bzr-builder format 0.2 deb-version {debupstream}-0~{revno}+{time} | 70 | # bzr-builder format 0.2 deb-version {debupstream}-0~{revno}+{time} |
410 | 71 | .""") | 71 | .""") |
412 | 72 | recipe_path = os.path.join(build_dir, 'rnr.recipe') | 72 | recipe_path = os.path.join(build_dir, 'uwc.recipe') |
413 | 73 | with open(recipe_path, 'w+') as recipe_file: | 73 | with open(recipe_path, 'w+') as recipe_file: |
414 | 74 | recipe_file.write(recipe) | 74 | recipe_file.write(recipe) |
415 | 75 | 75 | ||
416 | @@ -92,7 +92,7 @@ | |||
417 | 92 | 92 | ||
418 | 93 | def migrate_database(config_dir=None): | 93 | def migrate_database(config_dir=None): |
419 | 94 | if config_dir is None: | 94 | if config_dir is None: |
421 | 95 | # By default, the rnr config directory is assumed to be | 95 | # By default, the uwc config directory is assumed to be |
422 | 96 | # /home/username/django_project. | 96 | # /home/username/django_project. |
423 | 97 | config_dir = 'django_project' | 97 | config_dir = 'django_project' |
424 | 98 | run(config_dir + '/manage.py syncdb --migrate') | 98 | run(config_dir + '/manage.py syncdb --migrate') |
425 | @@ -133,7 +133,8 @@ | |||
426 | 133 | run("cp %s/local.cfg %s" % (backup_dir, config_dir)) | 133 | run("cp %s/local.cfg %s" % (backup_dir, config_dir)) |
427 | 134 | else: | 134 | else: |
428 | 135 | # Create a local.cfg on the server from our template. | 135 | # Create a local.cfg on the server from our template. |
430 | 136 | local_file, local_path = tempfile.mkstemp() | 136 | local_fd, local_path = tempfile.mkstemp() |
431 | 137 | local_file = os.fdopen(local_fd, 'w') | ||
432 | 137 | local_file.write(LOCAL_CONFIG) | 138 | local_file.write(LOCAL_CONFIG) |
433 | 138 | local_file.close() | 139 | local_file.close() |
434 | 139 | put(local_path, "%s/local.cfg" % config_dir) | 140 | put(local_path, "%s/local.cfg" % config_dir) |
435 | 140 | 141 | ||
436 | === modified file 'requirements.txt' | |||
437 | --- requirements.txt 2011-06-17 14:44:34 +0000 | |||
438 | +++ requirements.txt 2011-06-21 11:33:32 +0000 | |||
439 | @@ -1,7 +1,12 @@ | |||
440 | 1 | configglue==0.10 | ||
441 | 2 | coverage | ||
442 | 1 | django | 3 | django |
443 | 4 | django-configglue==0.4 | ||
444 | 5 | -e bzr+http://bazaar.launchpad.net/~canonical-isd-hackers/django-pgtools/trunk | ||
445 | 6 | django-preflight | ||
446 | 2 | mock | 7 | mock |
447 | 8 | PIL | ||
448 | 9 | python-debian | ||
449 | 10 | python-openid | ||
450 | 3 | setuptools | 11 | setuptools |
451 | 4 | south | 12 | south |
452 | 5 | python-debian | ||
453 | 6 | PIL | ||
454 | 7 | coverage | ||
455 | 8 | 13 | ||
456 | === modified file 'setup.py' | |||
457 | --- setup.py 2011-04-05 02:19:30 +0000 | |||
458 | +++ setup.py 2011-06-21 11:33:32 +0000 | |||
459 | @@ -1,5 +1,24 @@ | |||
460 | 1 | import os | ||
461 | 1 | from setuptools import setup, find_packages | 2 | from setuptools import setup, find_packages |
462 | 2 | 3 | ||
463 | 4 | def find_packages_data(start_dir): | ||
464 | 5 | packages = {} | ||
465 | 6 | for package_name in os.listdir(start_dir): | ||
466 | 7 | package_dir = os.path.join(start_dir, package_name) | ||
467 | 8 | if os.path.exists(os.path.join(package_dir, '__init__.py')): | ||
468 | 9 | files = [] | ||
469 | 10 | packages[package_name] = files | ||
470 | 11 | for dirpath, dirnames, filenames in os.walk(package_dir): | ||
471 | 12 | dirpath = dirpath[len(package_dir) + 1:] | ||
472 | 13 | for filename in filenames: | ||
473 | 14 | ext = os.path.splitext(filename)[1] | ||
474 | 15 | if ext not in ('.py', '.pyc', '.pyo'): | ||
475 | 16 | file_path = os.path.join(dirpath, filename) | ||
476 | 17 | full_file_path = os.path.join(package_dir, file_path) | ||
477 | 18 | if os.path.isfile(full_file_path): | ||
478 | 19 | files.append(file_path) | ||
479 | 20 | return packages | ||
480 | 21 | |||
481 | 3 | setup( | 22 | setup( |
482 | 4 | name = "ubuntu-webcatalog", | 23 | name = "ubuntu-webcatalog", |
483 | 5 | version = "0.1", | 24 | version = "0.1", |
484 | @@ -18,9 +37,6 @@ | |||
485 | 18 | 'django', | 37 | 'django', |
486 | 19 | 'south', | 38 | 'south', |
487 | 20 | ], | 39 | ], |
492 | 21 | package_data = { | 40 | package_data = find_packages_data('src'), |
489 | 22 | 'webcatalog': [ | ||
490 | 23 | ], | ||
491 | 24 | }, | ||
493 | 25 | ) | 41 | ) |
494 | 26 | 42 | ||
495 | 27 | 43 | ||
496 | === added file 'src/webcatalog/context_processors.py' | |||
497 | --- src/webcatalog/context_processors.py 1970-01-01 00:00:00 +0000 | |||
498 | +++ src/webcatalog/context_processors.py 2011-06-21 11:33:32 +0000 | |||
499 | @@ -0,0 +1,26 @@ | |||
500 | 1 | # -*- coding: utf-8 -*- | ||
501 | 2 | # This file is part of the Ubuntu Web Catalog | ||
502 | 3 | # Copyright (C) 2011 Canonical Ltd. | ||
503 | 4 | # | ||
504 | 5 | # This program is free software: you can redistribute it and/or modify | ||
505 | 6 | # it under the terms of the GNU Affero General Public License as | ||
506 | 7 | # published by the Free Software Foundation, either version 3 of the | ||
507 | 8 | # License, or (at your option) any later version. | ||
508 | 9 | # | ||
509 | 10 | # This program is distributed in the hope that it will be useful, | ||
510 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
511 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
512 | 13 | # GNU Affero General Public License for more details. | ||
513 | 14 | # | ||
514 | 15 | # You should have received a copy of the GNU Affero General Public License | ||
515 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
516 | 17 | |||
517 | 18 | """Context processors web catalog app.""" | ||
518 | 19 | |||
519 | 20 | from django.conf import settings | ||
520 | 21 | |||
521 | 22 | def google_analytics_id(request): | ||
522 | 23 | """Adds the google analytics id to the context if it's present.""" | ||
523 | 24 | return { | ||
524 | 25 | 'google_analytics_id': getattr(settings, 'GOOGLE_ANALYTICS_ID', None), | ||
525 | 26 | } | ||
526 | 0 | 27 | ||
527 | === added directory 'src/webcatalog/middleware' | |||
528 | === added file 'src/webcatalog/middleware/__init__.py' | |||
529 | === added file 'src/webcatalog/middleware/exception.py' | |||
530 | --- src/webcatalog/middleware/exception.py 1970-01-01 00:00:00 +0000 | |||
531 | +++ src/webcatalog/middleware/exception.py 2011-06-21 11:33:32 +0000 | |||
532 | @@ -0,0 +1,127 @@ | |||
533 | 1 | # -*- coding: utf-8 -*- | ||
534 | 2 | # This file is part of the Ubuntu Web Catalog | ||
535 | 3 | # Copyright (C) 2011 Canonical Ltd. | ||
536 | 4 | # | ||
537 | 5 | # This program is free software: you can redistribute it and/or modify | ||
538 | 6 | # it under the terms of the GNU Affero General Public License as | ||
539 | 7 | # published by the Free Software Foundation, either version 3 of the | ||
540 | 8 | # License, or (at your option) any later version. | ||
541 | 9 | # | ||
542 | 10 | # This program is distributed in the hope that it will be useful, | ||
543 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
544 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
545 | 13 | # GNU Affero General Public License for more details. | ||
546 | 14 | # | ||
547 | 15 | # You should have received a copy of the GNU Affero General Public License | ||
548 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
549 | 17 | |||
550 | 18 | """Exception logging middleware for the web catalog app.""" | ||
551 | 19 | |||
552 | 20 | import logging | ||
553 | 21 | import re | ||
554 | 22 | import sys | ||
555 | 23 | import traceback | ||
556 | 24 | |||
557 | 25 | from django.conf import settings | ||
558 | 26 | from django.db import connection | ||
559 | 27 | from django.views import debug | ||
560 | 28 | from django.views.debug import ExceptionReporter | ||
561 | 29 | |||
562 | 30 | default_hidden_settings = \ | ||
563 | 31 | 'SECRET|PASSWORD|PROFANITIES_LIST|PRIVATE|secret|password|private' | ||
564 | 32 | hidden_settings = getattr(settings, 'HIDDEN_SETTINGS', default_hidden_settings) | ||
565 | 33 | debug.HIDDEN_SETTINGS = re.compile(hidden_settings) | ||
566 | 34 | |||
567 | 35 | |||
568 | 36 | class SanitizedExceptionReporter(ExceptionReporter): | ||
569 | 37 | def __init__(self, request, exc_type, exc_value, tb, is_email=None): | ||
570 | 38 | request = self.sanitize_request(request) | ||
571 | 39 | ExceptionReporter.__init__(self, request, | ||
572 | 40 | exc_type, exc_value, tb) | ||
573 | 41 | |||
574 | 42 | def get_traceback_frames(self): | ||
575 | 43 | # This method is taken from Django's views.debug.ExceptionReporter. | ||
576 | 44 | # Please see the license file in the third-party/django directory. | ||
577 | 45 | frames = [] | ||
578 | 46 | tb = self.tb | ||
579 | 47 | while tb is not None: | ||
580 | 48 | # support for __traceback_hide__ which is used by a few libraries | ||
581 | 49 | # to hide internal frames. | ||
582 | 50 | if tb.tb_frame.f_locals.get('__traceback_hide__'): | ||
583 | 51 | tb = tb.tb_next | ||
584 | 52 | continue | ||
585 | 53 | filename = tb.tb_frame.f_code.co_filename | ||
586 | 54 | function = tb.tb_frame.f_code.co_name | ||
587 | 55 | lineno = tb.tb_lineno - 1 | ||
588 | 56 | loader = tb.tb_frame.f_globals.get('__loader__') | ||
589 | 57 | module_name = tb.tb_frame.f_globals.get('__name__') | ||
590 | 58 | pre_context_lineno, pre_context, context_line, post_context = \ | ||
591 | 59 | self._get_lines_from_file(filename, lineno, 7, loader, | ||
592 | 60 | module_name) | ||
593 | 61 | if pre_context_lineno is not None: | ||
594 | 62 | frames.append({ | ||
595 | 63 | 'tb': tb, | ||
596 | 64 | 'filename': filename, | ||
597 | 65 | 'function': function, | ||
598 | 66 | 'lineno': lineno + 1, | ||
599 | 67 | # The only diff in this method: call self.sanitize_vars() | ||
600 | 68 | 'vars': self.sanitize_vars(tb.tb_frame.f_locals.items()), | ||
601 | 69 | 'id': id(tb), | ||
602 | 70 | 'pre_context': pre_context, | ||
603 | 71 | 'context_line': context_line, | ||
604 | 72 | 'post_context': post_context, | ||
605 | 73 | 'pre_context_lineno': pre_context_lineno + 1, | ||
606 | 74 | }) | ||
607 | 75 | tb = tb.tb_next | ||
608 | 76 | |||
609 | 77 | if not frames: | ||
610 | 78 | frames = [{ | ||
611 | 79 | 'filename': '<unknown>', | ||
612 | 80 | 'function': '?', | ||
613 | 81 | 'lineno': '?', | ||
614 | 82 | 'context_line': '???', | ||
615 | 83 | }] | ||
616 | 84 | |||
617 | 85 | return frames | ||
618 | 86 | |||
619 | 87 | # These two methods are new -- Sanitize the request's POST and GET dicts, | ||
620 | 88 | # and local variables in frames, not only Django's settings. | ||
621 | 89 | def sanitize_vars(self, items): | ||
622 | 90 | sanitized = [] | ||
623 | 91 | for item in items: | ||
624 | 92 | if debug.HIDDEN_SETTINGS.search(item[0]): | ||
625 | 93 | sanitized.append((item[0], '********')) | ||
626 | 94 | else: | ||
627 | 95 | sanitized.append(item) | ||
628 | 96 | return sanitized | ||
629 | 97 | |||
630 | 98 | def sanitize_request(self, request): | ||
631 | 99 | """Remove sensitive from the request before it is displayed""" | ||
632 | 100 | dup_post = request.POST.copy() | ||
633 | 101 | for key in request.POST.iterkeys(): | ||
634 | 102 | if debug.HIDDEN_SETTINGS.search(key): | ||
635 | 103 | dup_post[key] = '********' | ||
636 | 104 | request.POST = dup_post | ||
637 | 105 | dup_get = request.GET.copy() | ||
638 | 106 | for key in request.GET.iterkeys(): | ||
639 | 107 | if debug.HIDDEN_SETTINGS.search(key): | ||
640 | 108 | dup_get[key] = '********' | ||
641 | 109 | request.GET = dup_get | ||
642 | 110 | return request | ||
643 | 111 | |||
644 | 112 | |||
645 | 113 | debug.ExceptionReporter = SanitizedExceptionReporter | ||
646 | 114 | |||
647 | 115 | |||
648 | 116 | class LogExceptionMiddleware(object): | ||
649 | 117 | def process_exception(self, request, exception): | ||
650 | 118 | """Log the traceback, so that it can be kept in the oops file""" | ||
651 | 119 | reporter = SanitizedExceptionReporter(request, *sys.exc_info()) | ||
652 | 120 | template_debug = settings.TEMPLATE_DEBUG | ||
653 | 121 | settings.TEMPLATE_DEBUG = True | ||
654 | 122 | try: | ||
655 | 123 | logging.warn(traceback.format_exc()) | ||
656 | 124 | for query in connection.queries: | ||
657 | 125 | logging.warn("time: %(time)s sql: %(sql)s" % query) | ||
658 | 126 | finally: | ||
659 | 127 | settings.TEMPLATE_DEBUG = template_debug | ||
660 | 0 | 128 | ||
661 | === added file 'src/webcatalog/schema.py' | |||
662 | --- src/webcatalog/schema.py 1970-01-01 00:00:00 +0000 | |||
663 | +++ src/webcatalog/schema.py 2011-06-21 11:33:32 +0000 | |||
664 | @@ -0,0 +1,61 @@ | |||
665 | 1 | import django | ||
666 | 2 | |||
667 | 3 | from configglue.pyschema import ConfigSection | ||
668 | 4 | from configglue.pyschema.options import (BoolConfigOption, StringConfigOption, | ||
669 | 5 | LinesConfigOption, IntConfigOption, DictConfigOption, TupleConfigOption) | ||
670 | 6 | from django_configglue.schema import ( | ||
671 | 7 | Django112Schema, | ||
672 | 8 | schemas, | ||
673 | 9 | ) | ||
674 | 10 | |||
675 | 11 | # Currently we've updated to latest configglue/django-configglue | ||
676 | 12 | # but they remove a registered schema for django 1.1.1, which is | ||
677 | 13 | # the currently installed django version on our servers, resulting in: | ||
678 | 14 | # http://razorgirl.info/job/software-center-agent-deploy/23/console | ||
679 | 15 | # So we register the 112 schema to match until we upgrade. Once we | ||
680 | 16 | # upgraded this should still work without updating (as the version | ||
681 | 17 | # will be 1.3). | ||
682 | 18 | schemas.register(Django112Schema, '1.1.1') | ||
683 | 19 | DjangoSchema = schemas.get(django.get_version()) | ||
684 | 20 | |||
685 | 21 | |||
686 | 22 | class WebCatalogSchema(DjangoSchema): | ||
687 | 23 | """Config options specific to the web catalog.""" | ||
688 | 24 | # default section | ||
689 | 25 | extra_pythonpath = LinesConfigOption(item=StringConfigOption()) | ||
690 | 26 | pgconnect_timeout = IntConfigOption(default=10) | ||
691 | 27 | should_serve_https = BoolConfigOption() | ||
692 | 28 | |||
693 | 29 | oops = ConfigSection() | ||
694 | 30 | oops.oops_dir = StringConfigOption(help='Absolute path to the directory' | ||
695 | 31 | ' oops reports will be stored in') | ||
696 | 32 | |||
697 | 33 | openid = ConfigSection() | ||
698 | 34 | openid.openid_sso_server_url = StringConfigOption() | ||
699 | 35 | openid.openid_create_users = BoolConfigOption() | ||
700 | 36 | openid.openid_update_details_from_sreg = BoolConfigOption() | ||
701 | 37 | openid.openid_launchpad_teams_mapping = DictConfigOption() | ||
702 | 38 | openid.openid_sreg_extra_fields = LinesConfigOption( | ||
703 | 39 | item=StringConfigOption()) | ||
704 | 40 | |||
705 | 41 | webcatalog = ConfigSection() | ||
706 | 42 | webcatalog.serve_site_media = BoolConfigOption(default=True) | ||
707 | 43 | webcatalog.sca_api_url = StringConfigOption() | ||
708 | 44 | webcatalog.disk_apt_cache_location = StringConfigOption() | ||
709 | 45 | |||
710 | 46 | google = ConfigSection() | ||
711 | 47 | google.google_analytics_id = StringConfigOption() | ||
712 | 48 | |||
713 | 49 | logging = ConfigSection() | ||
714 | 50 | logging.webapp_logging_config = StringConfigOption() | ||
715 | 51 | |||
716 | 52 | # preflight | ||
717 | 53 | preflight = ConfigSection() | ||
718 | 54 | preflight.preflight_base_template = StringConfigOption( | ||
719 | 55 | default="webcatalog/base.html") | ||
720 | 56 | |||
721 | 57 | #adminaudit | ||
722 | 58 | adminaudit_emails_recipients = LinesConfigOption( | ||
723 | 59 | item=StringConfigOption()) | ||
724 | 60 | adminaudit_summary_subject = StringConfigOption( | ||
725 | 61 | default='Admin Audit Summary') | ||
726 | 0 | 62 | ||
727 | === renamed directory 'django_project/templates/light' => 'src/webcatalog/templates/light' | |||
728 | === added file 'src/webcatalog/wsgi.py' | |||
729 | --- src/webcatalog/wsgi.py 1970-01-01 00:00:00 +0000 | |||
730 | +++ src/webcatalog/wsgi.py 2011-06-21 11:33:32 +0000 | |||
731 | @@ -0,0 +1,18 @@ | |||
732 | 1 | import logging.config | ||
733 | 2 | import platform | ||
734 | 3 | |||
735 | 4 | from canonical.oops.serializer import OOPSRFC822Serializer | ||
736 | 5 | from canonical.oops.wsgi import OopsWare | ||
737 | 6 | from django.core.handlers.wsgi import WSGIHandler | ||
738 | 7 | from django.conf import settings | ||
739 | 8 | |||
740 | 9 | def make_app(): | ||
741 | 10 | """Encapsulate our webcatalog handler in an OOPS app for error reporting.""" | ||
742 | 11 | default_id = ''.join(x for x in platform.node() if x.isalpha()) | ||
743 | 12 | appserver_id = getattr(settings, 'APPSERVER_ID', default_id) | ||
744 | 13 | logging.config.fileConfig(settings.WEBAPP_LOGGING_CONFIG) | ||
745 | 14 | oops_dir = getattr(settings, 'OOPS_DIR', '/tmp') | ||
746 | 15 | oops_app = OopsWare(WSGIHandler(), oops_dir=oops_dir, | ||
747 | 16 | key=appserver_id, hide_meta=True) | ||
748 | 17 | oops_app.serial = OOPSRFC822Serializer(appserver_id, oops_dir, None) | ||
749 | 18 | return oops_app |
There are still some RnR/SCA leftovers in the code, lines:
- 54 (mentions devportal),
- 676 (comment mentions sca-deploy)
Also, if you add user=postgres in [default_database], will enable to run against PostgreSQL without the need for one bit of config (and this setting is ignored by SQLite).