2476 Commits

Author SHA1 Message Date
Elrond
c4466cb4dc Add inspect_table.
In our current scheme of migrations, we reflect the current
sql schema into an SQLAlchemy schema. So let's have a tool
function for this.
2013-01-08 22:50:01 +01:00
Elrond
a050e776c6 Move all the migration tools into new migration_tools.py
Factor all the migration related stuff out into a new
.db.sql.migration_tools.
First we don't have to load this module for our normal
server.
Second it makes all the import dependencies a little more
cleaner.
2013-01-08 22:50:01 +01:00
Christopher Allan Webber
8e7354ef2b Fixing import to mediagoblin.db.base in stl models
Previously we had mediagoblin.db.sql.base, that just changed to drop
the sql; fixing.
2013-01-08 13:24:27 -06:00
Sebastian Spaeth
031d988c29 Merge branch 'WIP/test_performance' 2013-01-08 16:57:15 +01:00
Sebastian Spaeth
b97144dcc9 tests: More instances where a fresh database is not needed
Save test runtime by not dumping the databases when not needed.
2013-01-08 15:55:32 +01:00
Sebastian Spaeth
5018a3557c Don't read full image media into RAM on copying (#419)
We copy uploaded media from the queue store to the local workbench
and then to its final destination. The latter was done by simply:
dst.write(src.read()) which is of course evil as it reads the whole
file content into RAM. Which *might* arguably still be OK for
images, but you never know.

Make use of the provided storage() methods that offer chunked copying
rather than opening and fudging with files ourselves.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-08 14:51:41 +01:00
Sebastian Spaeth
40cec2b444 Don't get a fresh app when not needed
These tests, don't need fresh databases, so don't discard and recreate
the tables. This reduces test suite runtime on my laptop from 130 to 96
seconds.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-08 11:57:25 +01:00
Sebastian Spaeth
a5cf95c5ad Do not fail is a user exists already
When the tests want to create a new user, don't fail if it already
exists and just reuse the existing one. This allows us to run tests
without dumping the whole database if that is not needed for the tests.
The upcoming tests for test_edit will make use of this.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-08 11:54:44 +01:00
Sebastian Spaeth
7f4e42b0b1 Fix slug lookup regression (#587)
Removing the Mongo InvalidID legacy code removed an explicit check for
"int" for the id lookup. This led the @get_user_media_entry decorator to
fail if we looked up a nonexisting non-numerical slug (it tried to query
the id with a string, which failed). Cast id to int and return 404 in
case it is non-numeric which fixes the regression. It does not fix the
underlying problem of slug_or_id lookups that were discussed.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-08 08:59:32 +01:00
Joar Wandborg
76e6c2b15e Made the airy header element responsive again 2013-01-07 21:36:31 +01:00
Sebastian Spaeth
20be9bb77d Remove custom GMQuery class
We provided a custom GMQuery class that offered a .sort() method for
compatibility with the Mongo syntax. Now that we have settled for sqlalchemy
which uses the order_by() method, we can safely remove this custom class
and move a little closer to "pure" and native sqlalchemy usage.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-07 13:52:37 +01:00
Sebastian Spaeth
39dc3bf8db Mv db.sql.base to db.base
This concludes the db.sql.* -> db.* move. Our db abstraction layer is
sqlalchemy, so there is no need to a separate db.sql.* hierarchy.

All tests have been run for each of the commit series to make sure
everything works at every step.
2013-01-07 13:42:32 +01:00
Sebastian Spaeth
a5acfe23fa Move mediagoblin.db.sql.extratypes to mediagoblin.db.extratypes
No other functional changes.
2013-01-07 13:10:02 +01:00
Sebastian Spaeth
b0c8328e54 Move db.sql.models* to db.models* 2013-01-07 11:44:29 +01:00
Sebastian Spaeth
1e46dc2537 Move db.sql.util to db.util
Now that sqlalchemy is providing the database abstractions, there is no
need to hide everything in db.sql. sub-modules. It complicates the code
and provides a futher layer of indirection.

Move the db.sql.util.py to db.util.py and adapt the importers.
2013-01-07 11:31:56 +01:00
Sebastian Spaeth
0efe9e2796 Remove mediagoblin.db.sql.fake.DESCENDING
This is the last remnant that requires us to keep db.sql.fake.py. Use
ModelName.desc() or sqlalchemy.sql.expression.desc(column) to achieve
descending sorts.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-07 11:15:04 +01:00
Christopher Allan Webber
208842590c Also make slug unit test work with the new optionally-translitcodec-free code 2013-01-06 21:46:38 -06:00
Christopher Allan Webber
e535b9b36f Make translitcodec optional, and work nicely without it. 2013-01-06 21:41:08 -06:00
Joar Wandborg
78fa73bcd5 Made api_test use @require_active_login 2013-01-02 20:05:07 +01:00
Elrond
b228d89715 prepare_queue_task: Take app not request.
First rename prepare_entry to prepare_queue_task, because
this is really more like what this thing does.

Thanks to Velmont for noting that we do not need a request
in here, but an "app" is good enough. Which means, that
this stuff can be called from tool scripts too.
2012-12-26 23:42:26 +01:00
Elrond
01986008f6 upload refactor: Use prepare_entry in api. 2012-12-26 23:42:26 +01:00
Elrond
37f90b435d Use run_process_media in the api.
Now refactor in the api. Start with run_process_media.
2012-12-26 23:42:26 +01:00
Elrond
8eb47d02d9 Processing: Factor out prepare_entry.
prepare_entry handles the task_id setup and generating a
queue filename and file. it returns the queue file.
2012-12-26 23:42:26 +01:00
Elrond
86bb44ef12 Factor out the actual calling of the processing.
Calling the processing task and handling the exceptions is
easy, but has a bunch of caveats, so factor it out into an
easy callable function.
2012-12-26 23:42:26 +01:00
Elrond
be1f0f7d33 upload refactor: push url handling
Start to refactor our upload handling in main submit and
the api. Start factoring out the handling of PuSH url
handling.
2012-12-26 23:42:26 +01:00
Odin Hørthe Omdal
6e60238b6c Bug #584, upgrade EXIF.py from master to read Nikon data 2012-12-26 18:42:37 +01:00
Sebastian Spaeth
ab7281fe24 Fix up symlinks in exif bump
Previous exif bump copied the newer version into
mediagoblin/tools/extlib/exif but not in extlib/exif. Fix this by
bumping extlib/exif and symlinking to tools/extlib/exif.

Do note that this is still the version fetched from http://sourceforge.net/projects/exif-py/
while the upstream maintainer seems to be active on:
https://github.com/ianare/exif-py

(The sf.net download is quite new though)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-26 10:26:06 +01:00
Sebastian Spaeth
71717fd531 Remove ObjectId from the tree
This was one of the last remaining Mongo holdouts and has been removed from
the tree herewith. Good bye, ObjectId.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-25 20:52:25 +01:00
Sebastian Spaeth
c338ed34fa Remove temporary emacs files that have slipped in
Thanks Elrond for hilighting this :-)
2012-12-25 20:45:59 +01:00
Sebastian Spaeth
7c029a1f33 Remove InvalidId
It was a NoOp in our Non-mongo world. So it is safe to remove.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-25 20:28:19 +01:00
Sebastian Spaeth
9536988425 Move db.sql.migrations to db.migrations 2012-12-25 20:12:16 +01:00
Sebastian Spaeth
6eddc3b75e Move db.sql.open to db.open
Now that mongo has been ripped out and sqlalchemy is already providing
the database abstraction, there is no need to hide everything in the sql
module. Transition db.sql.open to db.open and adapt all direct importers.
2012-12-25 20:09:43 +01:00
Sebastian Spaeth
bc142abc55 RIP out mongo
Since sqlalchemy is providing our database abstraction and we have
moved away from Mongo as the underlying database, it is now time to
simplify things and rip out mongo. This provides the bulk of the
changes, and can stand on its own. There are some followup tasks
that can be done, such as removing now unneeded abstraction layers,
e.g. db.sql.fake.py
2012-12-25 20:06:03 +01:00
Sebastian Spaeth
351fd95fff Update extlib/EXIF
Bump bundled EXIF lib to 1.0.10 as release in Sep 2012.
Also skip unused detailed EXIF tags for reading, we might turn that
on when we need them.

Adapt test to wording change in EXIF Flas field and due to the fact
that we use "details=False" by default now (we did not use these
anyway)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-25 19:54:09 +01:00
Sebastian Spaeth
89672855f1 Merge branch '512_bump_video_js' 2012-12-25 19:18:23 +01:00
Sebastian Spaeth
565d01a09a Bump bundled video.js to v3.2.3 (#512)
There is nothing inherently wrong with the currently bundled version,
but the last one was uploaded in March 2012 and there have been
upstream releases since. So bump to the latest available release 3.2.3.

Might help with the reported issue 512 of an unresponsive video player.

Do note that the Flash fallback option is removed. If we decide
this should be added it is easy to add it back.

We still use our own customized theme.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-25 19:16:03 +01:00
Christopher Allan Webber
a1f9007bb0 makeadmin and changepasswd had swapped help text 2012-12-25 19:16:03 +01:00
Elrond
0562898e11 (SQL) Media types: Refactor backrefnames.
We need to know the name of the backref, so that we can
access it by name on the MediaEntry. We might be able to
get this name by inspection, but this way is easier, for
now.
2012-12-24 22:52:27 +01:00
Elrond
ac8212fe65 Remove mongo style .id = ObjectId()
On SQL we can't generate the primary key on our own. So
just remove this stuff.
2012-12-24 00:07:24 +01:00
Elrond
b39d1f2351 Mongo removal: Remove the validate=True arg to obj.save()
all callers were forced to use validate=True anyway. So
remove this useless stuff.
2012-12-24 00:07:24 +01:00
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