52 Commits

Author SHA1 Message Date
Christopher Allan Webber
64eab630bf Not only the web server starts MediaGoblin app! Better phrasing. 2014-01-02 15:07:54 -06:00
Rodney Ewing
26583b2cab check if db is up to date 2013-09-02 11:53:48 -07:00
Rodney Ewing
44082b12d8 Patch by Strum. Ticket #451 - Convert all mongokit style .find, .find_one, .one calls over to SQLAlchemy queries 2013-07-11 14:17:50 -07:00
Elrond
455fd36ff6 Use GenerateSlugMixin for collections.
Use the new way of generating slugs also for collections.
Also drop the dummy_db arg to check_collection_slug_used.
2013-04-06 16:53:04 +02:00
Sebastian Spaeth
65969d3fb7 Simplify check_media_slug_used
Remove the unused dummy_db argument and generally make the function
readable.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 14:49:50 +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
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
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
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
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
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
Aaron Williamson
be5be1154f Added basic collection functionality 2012-09-18 18:10:36 +02:00
Elrond
07163593ee Create function to search media by slug.
Searching media by slug is easy on mongo. But doing the
joins in sqlalchemy is not as nice. So created a function
for doing it.

Well, and create the same function for mongo, so that it
also works.
2012-03-16 21:20:14 +01:00
Elrond
b62b3b982a Generic check_media_slug_used db utility.
In two cases (generating a new slug and editing the slug)
it is nice to know in advance (before the db gets angry)
that the slug is used/free. So created a db utility
function to check for this on mongo and sql:
check_media_slug_used()
2012-03-05 21:37:05 +01:00
Elrond
325ca444d1 Implement atomic_update for SQL.
On sqlalchemy most updates are atomic enough for most use
cases. Anyway, here is an atomic_update that is compatible
to the mongo version.
2012-03-04 21:05:06 +01:00
Elrond
82cd968347 Create atomic_update db utility function
In some cases (notably the mark_entry_failed function) it
is useful to have atomic update functionality on the db. On
mongo this requires special syntax.

So created an atomic_update function for mongo and started
to use it in mark_entry_failed.
2012-03-04 20:58:19 +01:00
Christopher Allan Webber
cf29e8a824 It's 2012 all up in here 2012-02-02 09:44:13 -06:00
Elrond
d7bec8577e Add develover sql switch
If you want to play with the current state of sql, you need
a switch to turn it on. So here is the super secret
developer switch.

So you want to know where it is?

Here it is:

Create a file mediagoblin/db/sql_switch.py and put one line
in it: "use_sql = True" (or False to disable again). Right,
that's it. If you want to delete it, remember to delete the
*.pyc too.

Be careful not to "git add" it by accident!
2012-01-28 18:36:44 +01:00
Elrond
6a59a8abd4 Import MigrationManager from mongo in mongo backend.
Inside the mongo db backend, use the mongo
MigrationManager. This is hopefully the last reference to
the generic MigrationManager reference on db.util.
2012-01-04 22:31:52 +01:00
Elrond
59bd06aabb Move db/util.py -> db/mongo/util.py
- Change some reference
- Provide a wrapper db/util.py
2011-12-20 19:35:47 +01:00
Elrond
4970960f8c Move db/indexes.py to db/mongo/indexes.py
And change references (one!).
2011-12-20 19:20:09 +01:00
Nathan Yergler
285ffeddf3 has_key is deprecated, converting uses to use "in" operator. 2011-10-01 15:10:41 -07:00
Nathan Yergler
243c3843bd Whitespace and formatting cleanup.
* Removed trailing whitespace
* Line length < 80 where possible
* Honor conventions on number of blank lines
* Honor conventions about spaces around :, =
2011-10-01 15:10:02 -07:00
Will Kahn-Greene
12a100e4d8 508. Updates copyright/license information 2011-09-01 20:50:19 -04:00
Christopher Allan Webber
c47c37ed95 Merge branch 'master' into f411_new_migrations
Conflicts:
	mediagoblin/db/open.py
2011-07-13 23:14:42 -05:00
Christopher Allan Webber
59051a23f0 Duplicate migration numbers not allowed, bro 2011-07-13 22:32:51 -05:00
Christopher Allan Webber
511b10efda We should *raise* MissingCurrentMigration :)
Thanks for the catch, Elrond.
2011-07-13 20:58:13 -05:00
Christopher Allan Webber
dab0d24d98 Made it so that it's migrate_new() which installs the migration
version if missing, migrations_to_run just throws an error if not set
2011-07-10 22:02:51 -05:00
Christopher Allan Webber
0143c5a1e4 No reason to have migration_number optional or default to None 2011-07-10 18:48:09 -05:00
Christopher Allan Webber
9cf8b469e7 Move the call to install_migration_version_if_missing() to migrations_to_run()
This means there's a serious side effect of calling this, but there's
no way to get useful data here unless if that's set anyway.
2011-07-10 18:43:08 -05:00
Christopher Allan Webber
1b38cfa3b7 install_migration_version_if_missing() now a separate function
Also added it to MigrationManager.migrate_new(), because we'll always
need a migration number when migrating.
2011-07-10 18:27:38 -05:00
Christopher Allan Webber
8569533f21 Make sure all these strings in db/util.py are unicode 2011-07-10 16:23:36 -05:00
Christopher Allan Webber
d0ee0003a2 Simpler run_migrations method.
Allows for calbacks, should be useful for printing output and catching
things in tests.

Gets rid of the generator stuff which now that I think of it is a
messy idea.
2011-07-10 15:41:18 -05:00
Christopher Allan Webber
32ae9e1b4e Making sure migration_number > 0 :) 2011-07-09 18:17:54 -05:00
Christopher Allan Webber
ec86d16a53 run_new_migrations() makes more sense 2011-07-09 17:21:47 -05:00
Christopher Allan Webber
50bb8fe5e4 Changing things back so that we keep information about deprecated
indexes around.
2011-07-09 16:51:19 -05:00
Christopher Allan Webber
363fc97259 Some instructions in the RegisterMigration docstring on how to use. 2011-07-09 15:10:47 -05:00
Christopher Allan Webber
dca6406a90 latest_migration now returns migration numbers only, and 0 if no migrations. 2011-07-09 15:07:40 -05:00
Christopher Allan Webber
993f0a9321 Migrating quietly, not iteratively, that comment should say! 2011-07-09 14:51:48 -05:00
Christopher Allan Webber
51dcfb5682 New migration utility code.... I haven't tested this! ;)
I think it's looking right though.
 - Provides MigrationManager which should have plenty of utilities for
   doing migrations hopefully correctly :)
 - Provides RegisterMigration which should be able to decorate
   migrations and register them in doing so
2011-07-09 14:50:41 -05:00
Caleb Forbes Davis V
9c0fe63fad adds previous and next links in the sidebar
Feature #401 - previous/next navigation on media pages
* media.html includes a new prev_next.html template containing the links
* prev_next.html calls functions added to the media model to retrieve
  the appropriate objects from the database, formatted with urlgen
* a small change to util.py brings ASCENDING into the mix
2011-07-02 06:15:58 -05:00
Christopher Allan Webber
2527754202 Documenging index utils and adjusting how remove_deprecated_indexes gets arguments
More specifically, we now just take a dictionary of lists, like:
   {'collection': ['index_identifier1', 'index_identifier2']}

Previously we took something with more info like in add_new_indexes,
but that extra info isn't really necessary.
2011-06-27 20:48:35 -05:00
Christopher Allan Webber
0f3167c9f0 Tools to add / remove indexes from collections 2011-06-27 16:56:12 -05:00
Elrond
3efdd97c2e Move InvalidId to db.util
Instead of import InvalidId from the low level bson module,
first import it in our db.util wrapper and second import it
from pymongo.errors.
2011-06-20 00:09:40 +02:00
Elrond
a67fec8177 Factor out most of the database connection into db/open.py
I needed to split the db connection/opening into open.py,
due to an import loop:
- util.py needs db/util.py:ObjectId
- db/util.py would need db/models.py
- db/models.py needs util.py:slugify
2011-05-19 01:35:02 +02:00
Christopher Allan Webber
3262ad1dbb Renaming connect_database to connect_database_from_config and using in from_celery 2011-05-18 08:44:57 -05:00
Christopher Allan Webber
468bc8afce Need to import asint for users who specify ports via config file 2011-05-18 08:39:09 -05:00
Christopher Allan Webber
1815f5ce2e Adding copyright headers and explaining why these unused imports are here 2011-05-18 08:37:48 -05:00