2435 Commits

Author SHA1 Message Date
Elrond
1eac751bd2 Fix some unicode related issues in oauth and the api.
Found using the previous commit.
2012-12-23 23:55:44 +01:00
Elrond
601e6e0cce Testsuite: Turn SQLAlchemy warnings into errors
We should handle SQLAlchemy warnings. And to make that a
lot easier, turn them into real errors. That way they
1) Turn up more prominently.
2) Have a useful backtrace.

This only happens in the testsuite, so that normal useage
is not impacted.
2012-12-23 23:52:08 +01:00
Joar Wandborg
57c6473aa2 Added API tests 2012-12-23 21:45:46 +01:00
Elrond
05501c5742 Rewrite routing using new MGRoute class
MGRoute subclasses Rule():
Rule doesn't have a way to tag extra data, like the
controller function, we need. So MGRoute has a new
attribute .gmg_controller, which holds this.

Rewrite everything to use this new Rule variant and drop
all the other stuff that mapped endpoints to controller
functions, mostly.
2012-12-23 12:26:34 +01:00
Elrond
7880f03e2d Rewrite routing.py / get_url_map
Move most of the "init routing" code inside get_url_map().
Maybe not the best solution, but better than running the
init code directly at module load time.
2012-12-23 12:26:34 +01:00
Elrond
3d91433230 Move things from routing.py to tools/routing.py
This stops a cyclic import.

Move add_route, mount and endpoint_to_controller into
tools/routing.py and change all callers.
2012-12-23 12:26:34 +01:00
Elrond
48cf435d71 Refactor routing in app.py.
Move some things out of app.py into functions in
routing.py. This makes app.py a bit more readable and
allows us to rewrite routing.
2012-12-23 12:26:34 +01:00
Sebastian Spaeth
dfc23dd1e1 Compare user by id not object equality
Elrond correctly remarked that we should be comparing user by id
and not by comparing User objects (as I mistakenly did). He is
right, of course!

Also removing the 2 stray debug prints that were left over.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 12:12:11 +01:00
Sebastian Spaeth
2fb36dac31 Improve sqlalchemy filter rules
Thanks to Elrond's review. 1) Use filter_by more consistently
rather than mixing filter and filter_by. 2) Add multiple AND
conditions in the same filter rule rather than using separate
ones. 3) The atom feeds used filter_by(Modelname.attr == ...)
which was the wrong pattern, of course.

Thanks for repairing my junk Elrond!

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 12:08:51 +01:00
Sebastian Spaeth
cfa922295e Convert return HttpException to raise HttpException
controllers (view function) raise HttpException's and do not return them.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 11:58:51 +01:00
Sebastian Spaeth
785b287fcb Provide tools.response.render_http_exception and use that
After the webob->werkzeug transition, controller functions can raise
werkzeug.HttpExceptions. We need to catch these in app.py when calling
the controller and handle them, rendering the corresponding error Response()
object. For consistency, we also want to allow meddleware functions to
raise HttpExceptions (e.g. the csrf meddleware needs to complain about lack
of cookies), so wrap the request and response parts of the meddleware too.

Finally, the urlmap.match() can also raise HttpExceptions, so we give it the
same treatment (render_http_exception). I am not sure, if we do not need to
handle the Redirect exception there in any different way though...

The new function render_http_exception makes use of the render_error infrastructure
to return a nicely templated error page. It also checks if the stock error
messages was used in cases where we have localizations (403, 404) and use those.

It is now possible to do things like "raise Forbidden(_('You suckr'))" or
raise NotFound(_('where is my left show again')) if you want to return
customized error messages to the user.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 11:57:45 +01:00
Sebastian Spaeth
511d5b8966 Revert accidental checkin
Commit 8d19cb2445e2aa1f53431da26d866bf9b5e25872 accidentally included
my docs/source/build directory. Removing it again. Thanks to Elrond for
noticing.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-22 12:05:03 +01:00
Christopher Allan Webber
6991cb5bd5 We're in 0.3.3.dev territory now. 2012-12-21 09:08:52 -06:00
Sebastian Spaeth
70f8b2d046 Remove mongolisms from auth.views
Remove find find_one etc and use sqlalchemy syntax
2012-12-21 11:30:29 +01:00
Sebastian Spaeth
10f1f2f56b Remove Mongoism query.skip()
sqlalchemy supports slice() or [n:m] just fine.

Right now, it seems we cannot distinguish beween "empty" results
and out-of bound slices. It would be nice if we could distinguish
these somehow.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 11:30:29 +01:00
Sebastian Spaeth
af008743ca Remove mongolisms from user_pages.view #451 2012-12-21 11:30:29 +01:00
Sebastian Spaeth
f6bc033603 Refactor media_collect
Remove lots of MOngolisms. Refactor this to remove some indentation
levels. Don't do:
 if success:
   ...
   if success:
     ....
     if success:
     ...
2012-12-21 11:29:39 +01:00
Sebastian Spaeth
2783c65988 Merge branch '577_denoise_video_transcoding' 2012-12-21 09:11:21 +01:00
Sebastian Spaeth
573b4305cd Don't dbug log every added plugin route
It is killing testsuite output by drowning out all signals. It should
be sufficient to state in the pluginmanager that routes have been added,
if we need that kind of output.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:59:37 +01:00
Sebastian Spaeth
8d19cb2445 Don't require webob as dependency
It is pushing up the daisies. Also relnote the change.
2012-12-21 08:24:28 +01:00
Sebastian Spaeth
726896b62a Remove webob compatability
Remove the aliases we provided for webob compatability as webob is
now gone. Grepped the code base to check for occurences of the old
parameters to be safe. Keep request.GET attribute as alias for
request.args as it is often used and django is also using that
attribute.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
cc195d5b82 plugins/api: webob.Response -> werkzeug.Response 2012-12-21 08:12:25 +01:00
Sebastian Spaeth
7c552c0bd7 plugins/api: use headers.set(), not headers.update()
The werkzeug.Response().headers do not offer an update() method as
the same key can be twice in the header 'dict'. Thus, iterate over
the header keys and use header.set(key, value) which replaces an
existing header key.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
74af60bb32 replace webob.Response with werkzeug Response
Replace webob usage in one more file. Document a TODO that should
be clarified, we should probably be using json_response rather than
Response() here.

Modify the TestMeddleware to not rely on the content_type attribute
being present, while werkzeug.wrappers Response() has it the BaseResponse()
object which is often returned in tests does not have it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
bf3b9e783d Transition webob BadRequest|HTTPFound to webob/redirect
More transitioning away from webob
Response import from webob was unused
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
0eff207dff tests/auth: Don't rely on case sensitive error strings
webob's 404 status is "404 NOT FOUND" while werkzeug's is
"404 Not Found". Our test suite was checking the upper case string
for equality. Just test the status error code "404" rather than the
full string which might change at some points/versions and should
not need to be tested.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:12:25 +01:00
Sebastian Spaeth
950124e640 webob.HTTPFound --> MG.tools.redirect
Transition away from webob.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
62d14bf50b Transition webob.HttpForbidden to webob's exceptions Forbidden
Also the BadRequest exception.
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
059eaee4df Remove webobisms from decorators.py
Use our own redirect function rather than webobs HttpFound
Also replace HttpForbidden() with webob's Forbidden()
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
53f528cfea purge webob from docs and replace with werkzeug 2012-12-21 08:10:48 +01:00
Sebastian Spaeth
b745bb50d8 Remove webob from render_to_response
We were still using webob's Response objects for template rendering.
Transition to werkzeug's Response object. One caveat was that it
seemed to have used the default mimetype "text/plain" for all pages,
so we override the default Response class, setting the default mime
type to "text/html".

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:10:48 +01:00
Sebastian Spaeth
4487d51c81 Extend redirect helper to take optional location keyword
In order to move away from webob with its redirect(location=...) we
need to provide a redirect function that allows to directly specify
the URL rather than the urlgen parameters that we now use.

Extend our MG.tools:redirect helper so we can pass in the direct URL
via the optional "location" keyword.

This commit does not switch over any redirect consumers yet.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:10:48 +01:00
Sebastian Spaeth
30bb4109bc Remove SimpleFieldAlias
It was only used for the model._id -> model.id conversion and is not
needed anymore.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Sebastian Spaeth
5c2b84869f Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is
what Mongo uses. However, each use of _id required a) fixup of queries:
e.g. what we did in our find() and find_one() functions moving all
'_id' to 'id'. It also required using AliasFields to make the ._id
attribute available. This all means lots of superfluous fixing and
transitioning in a SQL world.

It will also not work in the long run. Much newer code already refers
to the objects by model.id (e.g. in the oauth plugin), which will break
with Mongo. So let's be honest, rip out the _id mongoism and live with
.id as the one canonical way to address objects.

This commit modifies all users and providers of model._id to use
model.id instead. This patch works with or without Mongo removed first,
but will break Mongo usage (even more than before)

I have not bothered to fixup db.mongo.* and db.sql.convert
(which converts from Mongo to SQL)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Sebastian Spaeth
7e55bcb898 Fix up tests
empty find() queries would not work anymore with the simplified .find
compatability code, so remove these and use proper sqlalchemy in the
tests.

The storage test failed because my virtualenv environment ran
mediagoblin/local/mediagoblin/tests/test_storage.py and somehow decided
the 2 classes are different objects. Just test against the full class name.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Christopher Allan Webber
5c99cd01a7 Fixing tyop'ed "dbupdate" 2012-12-20 13:54:03 -06:00
Christopher Allan Webber
f822ab0de9 NOW RELEASING: MediaGoblin 0.3.2! :D 2012-12-20 11:16:29 -06:00
Christopher Allan Webber
6a9f537e6c Committing extracted and compiled translations 2012-12-20 10:11:54 -06:00
Christopher Allan Webber
7d7def6510 Committing present MediaGoblin translations before pushing extracted messages 2012-12-20 10:11:34 -06:00
Christopher Allan Webber
1f01df1dfc 0.3.2 release notes 2012-12-20 09:48:47 -06:00
Christopher Allan Webber
231a06f2d0 Updating AUTHORS with new contributors. Nice job new contributors! :) 2012-12-20 09:27:56 -06:00
Christopher Allan Webber
f4fe38d8e0 Committing extracted and compiled translations 2012-12-20 09:19:50 -06:00
Christopher Allan Webber
3fe3b2229c Docs fix: Adding proper blank line after the "Run::" 2012-12-20 08:23:03 -06:00
Christopher Allan Webber
5ef7ab084f Added documentation on how to add STL support, and notes on running ./bin/gmg dbupdate 2012-12-20 08:18:56 -06:00
Sebastian Spaeth
0efc4e4dbf Only log output and write progress to db if it has changed
De-noisify the transcoding log and db updates. Previously we would log
and save the progress percentage every second, even if it had not changed
at all. Save progress:oercentage in the Transcoder and only log/update
when the percentage has actually changed.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-19 15:48:30 +01:00
Sebastian Spaeth
4d9b426ccf Try ipython-based shell first, falling back to plain shell
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-19 10:33:29 +01:00
Christopher Allan Webber
b28005984c makeadmin and changepasswd had swapped help text 2012-12-18 16:46:20 -06:00
Jef van Schendel
98b927250e Remove collection_thumbnail styling, so collection thumbnails are styled the same as other thumbnails 2012-12-16 21:57:19 +01:00
Sebastian Spaeth
cacb6feae4 Release note 0.3.2 blurb
On MongoDB...
2012-12-15 21:00:41 +01:00
Christopher Allan Webber
9d5cd0b924 Adding info to the docs about running dbupdate
Both adding info to run it when adding new media types, and adding
info that you might need to stop mediagoblin before you run these
commands.
2012-12-14 18:29:00 -06:00