363 Commits

Author SHA1 Message Date
Aaron Williamson
c8035da197 Added migration for license field, resolved conflict in db/sql/models.py 2012-01-19 22:00:08 -05:00
Elrond
fbad3a9fb9 Add copyright header and a bit of pep8ification
Nearly all the sql files missed a copyright header.
So added it!
And while there fixed a few pep8 things.
2012-01-20 00:17:05 +01:00
Elrond
92edc74e9b Use custom query class
A custom query class allows to add more methods on
queries (read: "cursors").

This custom query class especially adds a .sort with a
calling convention exactly like the mongo one.
Makes a lot of existing code happy!
2012-01-20 00:00:57 +01:00
Aaron Williamson
17c23e15e4 Moved get_license_data to mixin.py, added license to sql media model, added translation tags to license template. 2012-01-18 21:07:55 -05:00
Aaron Williamson
291e24f397 Merge branch 'mediagoblin-upstream' into feature544_basic_license_data 2012-01-18 20:40:18 -05:00
Elrond
6fc8af3278 sql/fake.py: Some fake objects/methods to calm the code
sql/fake.py contains some fake classes and functions to
calm the rest of the code base. Or provide super minimal
implementations.

Currently:
- ObjectId "class": It's a function mostly doing
  int(first_arg) to convert string primary keys into
  integer primary keys.
- InvalidId exception
- DESCENING "constant"
2012-01-18 23:35:55 +01:00
Aaron Williamson
a6c49d49dc Fixed a syntax error in edit/views and added back in some missing license stuff from models 2012-01-17 01:22:02 -05:00
Aaron Williamson
25bdf9b657 Fixed merge with upstream 2012-01-17 01:05:15 -05:00
Aaron Williamson
99a270e952 Merged changes with upstream 2012-01-17 00:59:21 -05:00
Aaron Williamson
25b48323a8 First crack at basic license support. 2012-01-17 00:33:55 -05:00
Elrond
02db7e0a83 Add MediaFile table and related infrastructure.
- This adds a new SQL table field type for path tuples.
  They're stored as '/' separated unicode strings.

- Uses it to implement a MediaFile table.

- Add relationship and proxy fields on MediaEntry to give a
  nice media_files "view" there.

- Let the converter fill the MediaFile.
2012-01-11 12:19:03 +01:00
Elrond
cb7ae1e433 Fix url_for_self mixup
Move changes from mongo/models:url_for_self back into
mixin:url_for_self.
2012-01-11 11:16:35 +01:00
Christopher Allan Webber
73079ac4b8 Merge branch 'master' of gitorious.org:mediagoblin/mediagoblin
Conflicts:
	mediagoblin/db/mongo/models.py
2012-01-10 08:12:30 -06:00
Michele Azzolari
1df68a3524 Fixed #724 and added extra infos to the atom feed (author uri and links to the html version of each entry) 2012-01-10 08:10:53 -06:00
Elrond
f42e49c3ad Add DB Mixin classes and use them
A bunch of functions on the db objects are really more like
"utility functions": They could live outside the classes
and be called "by hand" passing the appropiate reference.
They usually only use the public API of the object and
rarely use database related stuff.

Goals:
- First, simple: Share the code with the SQL objects, so
  that the code doesn't need to be duplicated.
- Second, it might unclutter the db models and make them
  more into "model only" stuff.
- Doesn't really hurt.
2012-01-08 21:55:46 +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
010fe2d71b sql convert: Use more library functions
1. Use the new setup_connection_and_db_from_config in the
   sql backend.

2. Use sql and mongo specific functions wherever
   appropiate instead of the generic "db.X" one. This makes
   the converter more indepedent of the current backend
   choice.
2012-01-01 23:51:14 +01:00
Elrond
415077a743 Factor out check_db_migrations_current
When initializing the database connection the current mongo
based setup checked for new migrations and warned about
them. This was mongo specific so factor'd it out into a
more generic check_db_migrations_current function in the
mongo backend.

Also created a dummy one in the sql backend.
2012-01-01 18:36:42 +01:00
Elrond
9f264942d8 Add a .save method on the sql db objects
This is a shortcut to adding the object to a session (if
needed) and giving a commit on the session.

In reality, calling code should probably utilize the
session on its own and call commit in an appropiate place.
2011-12-29 10:41:50 +01:00
Elrond
03c2286232 Support .get(fieldname) on sql db objects
Some parts of the code like to call .get("somefield") on
the db objects.  It's easy to support this on sqlalchemy
based objects, so lets do it.
2011-12-29 00:14:47 +01:00
Elrond
88e90f41eb SQL Model: Add relationship properties
MediaEntry now has a get_uploader (property) loading the
appropiate User object for the MediaEntry (and caches it).
MediaComment has the same for author as get_author.
2011-12-28 22:58:44 +01:00
Elrond
c6263400cf SQL Model: Forgot MediaEntry.state field
While creating the new SQL model, the "state" field of
MediaEntry was left out. Currently using a plain unicode
string for it.

Maybe should use sqlalchemy.types.Enum?
2011-12-28 22:58:32 +01:00
Elrond
19ed039ba6 Implement _id proxy on sql objects (on User for now)
So that the old code can access the primary key still as
"._id".

Quite simple Python Descriptor thing.
Very generic.
2011-12-28 22:26:00 +01:00
Elrond
0575175846 Turn media.get_uploader into a property
sqlalchemy gives autoloading (hopefully caching) link to
other objects as properties. So turn get_uploader on the
current mongo based stuff into a property to ease
transition.
2011-12-27 20:41:31 +01:00
Elrond
0eb649ff7a Use media.url_for_self instead of calling urlgen directly
Replace
	urlgen('ID', user=media.get_uploader().username, media=media.*)
by
	media.url_for_self(urlgen)
in a few places.
It's just a lot nicer!
2011-12-27 20:41:31 +01:00
Elrond
479e8a833b Move verification key generation to view
Instead of creating the email verication key on the db
model as a default for the field, create it in the
registration view.
Now all verification key generation is only in
auth/views.py!
2011-12-27 20:17:16 +01:00
Elrond
4305580e85 Improve .one() by using sqlalchemy's .one() 2011-12-24 19:11:42 +01:00
Elrond
2608982885 Add search level one() method
And create a _fix_query_dict which converts '_id' to 'id'.
2011-12-24 19:11:12 +01:00
Elrond
fb7dd855de Turn MediaComment's author() into get_author property
1) MediaComment's author method conflicts with the author
   field. So rename it to get_author.
2) Turn it from a normal function into a python property.
   That means you call it by ".get_author" not by
   ".get_author()". This is exactly what sqlalchemy gives
   us free of charge.
2011-12-23 22:25:06 +01:00
Elrond
4ae4012dad Move db/models.py -> db/mongo/models.py
To my surprise, there was only ONE reference to models.py.
From open.py.
2011-12-20 20:41:21 +01:00
Elrond
faf74067da Move db/migrations.py -> db/mongo/migrations.py
And change references.
2011-12-20 20:33:33 +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
Elrond
046f9f8481 Move db/open.py to db/mongo/open.py
Starting to move the mongo specific stuff into db/mongo.
And create thin "from db.mongo.Y import z" wrappers in
db/Y.py.

Why?
1) Will make it lots easier to switch to sql for
   testing/developing.
2) The mongo stuff needs to stay around after moving to
   sql, because the converter needs it.
2011-12-20 19:06:04 +01:00
Elrond
7b194a79f0 SQL: mongokit like interface
In trying to ease the migration to SQL, created an
interface to sqlalchemy that looks a lot like the interface
that is currently in use.

*WARNING* Work in progress
2011-12-18 17:07:15 +01:00
Elrond
dbcf5289dc Simple Mongo -> SQL migration tool
This is just a start at a Migration tool from Mongo to SQL.
It fills all currently available SQL models with data from
MongoDB. A few fields in the SQL tables are left out,
because some data format migrations are needed (notably:
queue_file_name).

This thing lives in mediagoblin/db/sql/convert.py because
it has a lot of stuff hardcoded and is not, repeat not for
end users!

Hard coded:
- output database: ./mediagoblin.db (sqlite)
- Mediagoblin config: ./mediagoblin.ini
2011-12-17 21:37:02 +01:00
Elrond
7c2c56a5ff Little sql model update
- Add title to the MediaEntry
- Rename fp_verification_expire to fp_token_expire to
  follow the mongo model.
2011-12-17 17:34:55 +01:00
Elrond
e365f980ac SQL: Some toys and little fix
Run bin/python mediagoblin/db/sql/models.py and watch the
create tables on a memory sqlite db.

Also unicode strings need unicode defauls. Warning by
sqlalchemy.
2011-12-15 22:11:49 +01:00
Elrond
a8ae9a29c1 Move sql models into db/sql/
So we can play with the sql models, let's put them in a
proper place.
2011-12-15 21:15:21 +01:00
Elrond
a0033abb9b Merge remote branch 'remotes/cwebber/sqlalchemy'
* remotes/cwebber/sqlalchemy:
  Beginnings of sqlalchemy models
2011-12-15 21:10:01 +01:00
Elrond
ddc1cae9ea Dot-Notation for MediaEntry.media_data 2011-12-05 21:08:58 +01:00
Elrond
5da0bf901b Dot-Notation for MediaEntry.slug 2011-12-05 21:08:58 +01:00
Elrond
ec82fbd85c Dot-Notation for MediaEntry.title 2011-12-05 21:08:58 +01:00
Elrond
1ceb4fc868 Dot-Notation for MediaEntry.uploader 2011-12-05 21:08:58 +01:00
Elrond
9047b254f3 Dot-Notation for Users.pw_hash 2011-12-05 21:08:57 +01:00
Elrond
5a4e3ff1e2 Dot-Notation for Users.username 2011-12-05 21:08:57 +01:00
Christopher Allan Webber
99d2ac1d83 Merge remote-tracking branch 'remotes/jwandborg/master' 2011-11-24 15:24:58 -06:00
Elrond
3018832153 Rename MediaEntry.uploader() to .get_uploader()
The .uploader() method conflicts with the uploader database
field. As we're moving to .FIELD for db field access, this
is a relevant conflict.

So renaming .uploader() to .get_uploader()
2011-11-22 22:29:37 +01:00
Joar Wandborg
b9e1fa280e Merge branch 'video_gstreamer-only'
Conflicts:
	mediagoblin/db/migrations.py
	mediagoblin/submit/views.py
2011-11-21 21:51:30 +01:00
Pablo J. Urbano Santos
e62fc61194 Added parameter ascending to MediaEntry::get_comments, if true, comments
will be ordered ascending, otherwise descending
2011-11-19 19:11:42 +01:00