aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools
Commit message (Collapse)AuthorAgeFilesLines
* Move db.sql.models* to db.models*Sebastian Spaeth2013-01-071-1/+1
|
* Make translitcodec optional, and work nicely without it.Christopher Allan Webber2013-01-061-3/+12
|
* Fix up symlinks in exif bumpSebastian Spaeth2012-12-262-1916/+1
| | | | | | | | | | | | | | 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>
* Remove ObjectId from the treeSebastian Spaeth2012-12-252-2/+2
| | | | | | | 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>
* Remove InvalidIdSebastian Spaeth2012-12-251-9/+3
| | | | | | It was a NoOp in our Non-mongo world. So it is safe to remove. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* RIP out mongoSebastian Spaeth2012-12-251-1/+1
| | | | | | | | | 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
* Update extlib/EXIFSebastian Spaeth2012-12-253-3/+1917
| | | | | | | | | | | | 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>
* Rewrite routing using new MGRoute classElrond2012-12-231-12/+15
| | | | | | | | | | | 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.
* Move things from routing.py to tools/routing.pyElrond2012-12-231-0/+63
| | | | | | | This stops a cyclic import. Move add_route, mount and endpoint_to_controller into tools/routing.py and change all callers.
* Provide tools.response.render_http_exception and use thatSebastian Spaeth2012-12-231-0/+19
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove Mongoism query.skip()Sebastian Spaeth2012-12-211-2/+5
| | | | | | | | | | 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>
* Remove webob from render_to_responseSebastian Spaeth2012-12-211-1/+5
| | | | | | | | | | 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>
* Extend redirect helper to take optional location keywordSebastian Spaeth2012-12-211-10/+17
| | | | | | | | | | | | | 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>
* Move DBModel._id -> DBModel.idSebastian Spaeth2012-12-212-3/+3
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Switching both gettext calls to _() so babel can find/extract them.Christopher Allan Webber2012-12-141-4/+6
| | | | Babel looks for _() and gettext() so this is necessary.
* Add comments explaining how translitcodec *is* usedChristopher Allan Webber2012-12-141-0/+2
|
* Add example to the lazy gettext version to make clear when it's appropriateSebastian Spaeth2012-12-141-1/+4
| | | | I needed an example to really get when lazy_gettext would be good...
* Use the correct translation mechanismSebastian Spaeth2012-12-141-3/+4
| | | | | | | We accidentally used the fake translation mechanism here which will not actually translate anything. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Remove gridify_*Sebastian Spaeth2012-12-041-31/+0
| | | | | | | | | | | | | We injected a gridify_list and gridify_cursor function into each jinja2 template that we render. This was used to split the list of media_entries into batches of 5 for nicer table columns. However, jinja2 has a nice |batch filter built in that does the job for us just as well with less code (on our side) Less code=good so let's merge this one. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fallback to "en_US" if browser does not send preferred languagesSebastian Spaeth2012-12-041-16/+13
| | | | | | | | | | | | | E.g. in our test suite we don't send an "accepted languages" header, which caused the language matching to fail. So we need to explicitely fallback to en_US, in case request.accepted_languages is None. This fixes the tests and all cases where user browsers don't send preferred languages. This also fixes issue #562, the AVAILABLE_LOCALES are already case-normalized and we don't need to fudge the preferred language through the lower_upper_locale thing for each and every request. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Provide jinja2 urlencode filterSebastian Spaeth2012-12-031-0/+4
| | | | | | | | | | | Astonishingly, the great jinja2 does not provide a builtin urlquote filter, although it is obviously needed. (jina1 had one) This is: https://github.com/mitsuhiko/jinja2/issues/17 Provide an urlencode filter, based on werkzeug's url_quote_plus function. This is dead easy to implement and gives us all the freedom we want. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* en_US is always availableSebastian Spaeth2012-12-021-7/+8
| | | | | | | | | | | We were using "en" as fallback only when no preferred language matched. This is obviously bad. Always insert en_US as available locale, so we can match it with the accept_languages. Don't set available_locales as mg_global, per discussion with paroneaya, make it a global var in translate.py Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fixing bug where not all conditions returned a language in ↵Christopher Allan Webber2012-12-011-1/+2
| | | | | | get_locale_from_request() Just had to change the indentation level of the last commit.
* Fall back to "en" if we don't find matching translationsSebastian Spaeth2012-12-021-1/+1
| | | | | | | | In case of no matching translations, target_lang was "None" which blew up things. Fall back to "en" in case we don't find a corresponding translation. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Honor user's browser language (#558)Sebastian Spaeth2012-12-022-11/+21
| | | | | | | | | | | | | Previously we would attempt to satisfy the user's first language preference, immediately falling back to english if that was not possible. Now, we will get the best match of the user's preferred languages. This requires storing the available locales on app startup, so we have mg_globals.available_locales ready to compare them against the list of preferred user languages. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fix i18n in our browserSebastian Spaeth2012-12-011-12/+13
| | | | | | | | | | | | | | | | | | We only ever served english pages since the switch to werkzeug's requests. Fix this by actually checking the accepted languages that our web browser sends and using that or falling back to english. This is not optimal, imaging our browser sends "klingon, de" as accepted languages and we happen to not have a klingon translation ready (a deficiency that should be corrected immediately anyway!!). We would then fall back to english rather than sending the sensible and pleasant German language which the user would understand. This will require more backend work though. Removing the gettext.find() in mg_globals.py. It looked in the wrong directory anyway (mediagoblin/translations) and as that does not exist, had always returned None without anyone noticing. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Implement licenses.get_license_by_urlSebastian Spaeth2012-11-301-0/+10
| | | | | | | | | Rather than exploding in the user's face (for example if we custom-configure licenses in our MG instance, and there are still media with now "unknown" licenses in the db), simply return a License object as a fallback, where all attributes are set to the URL we were handed. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Improve mediagoblin.tools.licensesSebastian Spaeth2012-11-301-34/+38
| | | | | | | | | "Objectify" our licenses to have .uri, .abbreviation, .name attributes that we can pass into the templates and use there. namedtuples are a good poor man's choice to make a License a class. (a named tuple really) Document and optimize licenses_as_choices(), it is a one-liner really. No need for verbose appends here...
* Merge remote-tracking branch 'spaetz/formerge/538_FORBIDDEN_admin_pages'Elrond2012-11-291-5/+26
|\ | | | | | | | | | | | | * spaetz/formerge/538_FORBIDDEN_admin_pages: Fix error page text Return code 403 when accessing admin pages Implement generic error pages
| * Fix error page textSebastian Spaeth2012-11-291-2/+2
| | | | | | | | | | | | | | Thanks to Elrond for noticing. We wrap error messages in <p> tags, so there is no need to start the error message with <p>. DOH Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
| * Implement generic error pagesSebastian Spaeth2012-11-291-5/+26
| | | | | | | | | | | | | | | | | | | | | | Rather than having a 404.html, a 403.html, a 500.html,... we have a generic error.html template that we pass in an error code, a title and a (html'ish) error message. Implement the common render_404 and render_403 shortcuts. More exotic cases can be achieved by the generic render_error function. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Merge remote-tracking branch 'spaetz/formerge/507_remove_routes'Elrond2012-11-291-6/+4
|\ \ | |/ |/| | | | | * spaetz/formerge/507_remove_routes: Purge routes package from MG (#507)
| * Purge routes package from MG (#507)Sebastian Spaeth2012-11-201-6/+4
| | | | | | | | | | | | | | | | | | We were not actually using the routes package anymore, but it was still mentioned in the documention. Adapt the plugin documentation to actually represent reality, although I don't like the API design. (but this is for another day) Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | No need to strip the tag 4 timesSebastian Spaeth2012-11-161-5/+4
| | | | | | | | | | | | spaetz' rule: Don't do sth 4 times when once suffices. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Slightly shorten the media_tags_as_string functionSebastian Spaeth2012-11-141-5/+3
| | | | | | | | Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Remove tag delimiter configurability (#390), fixed pep-8 compliancedunkyp2012-11-141-8/+7
|/ | | | | | | | Hardcode commas as tag delimiters per discussion in issue 390. Also improved PEP-8'ness of the file while touching. Includes some improvements suggested by gandaro. Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* Fixed OAuth access_token duplicate routeJoar Wandborg2012-10-151-0/+1
| | | | Changed route name to "[...]list_connections"
* Fixed 404 page under werkzeug.routingJoar Wandborg2012-10-141-6/+1
| | | | | - Removed ?lang=<langcode> feature due to incompatibility with werkzeug routes in the current state of the architecture.
* Switched most stuff over from RoutesJoar Wandborg2012-10-141-1/+1
| | | | | | | | | | Removed the Routes routing functionality and replaced it with werkzeug.routes. Most views are functional. Known issues: - Translation integration with the request object is not yet figured out. This breaks 404 pages.
* Fixed pylint issues, removed unused importJoar Wandborg2012-10-021-1/+0
|
* Changed copy.copy(get_params) to dict(get_params)Joar Wandborg2012-09-301-1/+1
| | | | | in pagination because request.GET/request.args is immutable since the switch to werkzeug.
* Replaced all request.POST with request.form, ...Joar Wandborg2012-09-291-1/+1
| | | | | - Fixed error handling in OAuth plugin - Changed request.POST file fields to request.files
* Switch from webob.Request to werkzeug.wrappers.RequestJoar Wandborg2012-09-291-13/+4
|
* Added tests for HTTP callbacksJoar Wandborg2012-09-271-0/+9
|
* HTTP callback fixesJoar Wandborg2012-09-261-4/+11
| | | | | | | | | | | - Added HTTPError catching around the callback request, to not mark the entry as failed, just log the exception. - Fixed bug where I forgot to actually fetch the entry before passing it to json_processing_callback. - Changed __main__ migration #6 to create the ProcessingMetaData table as it is currently, to prevent possible breakage if a siteadmin is lagging behind with his db migrations and more than one migration wants to fix stuff with the ProcessingMetaData table.
* Added support for http callbacks on processingJoar Wandborg2012-09-261-0/+73
| | | | | Sends an HTTP POST request back to an URL given on submission to the API submit view.
* Added flask-wtf html5 fields to extlibJoar Wandborg2012-09-211-0/+1
|
* Created API plugin, moved api_auth to the API pluginJoar Wandborg2012-09-131-29/+0
|
* Add OAuth models, plugin DB migrations, api_authJoar Wandborg2012-09-131-1/+34
|
* Fix for issue #491, invert latitude when neccesary.warp2012-08-271-0/+3
|