aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools
Commit message (Collapse)AuthorAgeFilesLines
* simplified get_usefulAndrás Veres-Szentkirályi2013-02-221-6/+1
|
* use dict.iteritems() instead of dict.items()András Veres-Szentkirályi2013-02-221-1/+1
|
* use list expression instead of 3-deep forAndrás Veres-Szentkirályi2013-02-221-7/+2
|
* simplified clean_exifAndrás Veres-Szentkirályi2013-02-221-6/+2
|
* close file properly and remove unneeded variableAndrás Veres-Szentkirályi2013-02-221-6/+2
|
* typofix in commentAndrás Veres-Szentkirályi2013-02-221-1/+1
|
* use key in dict instead of key in dict.keys()András Veres-Szentkirályi2013-02-221-1/+1
|
* Merge remote-tracking branch 'pythonsnake/537_version'Elrond2013-02-191-0/+2
|\ | | | | | | | | | | * pythonsnake/537_version: Added "version" before the version Fix bug 537
| * Fix bug 537pythonsnake2013-02-101-0/+2
| |
* | Fix deleting media with attachments.Elrond2013-02-181-1/+1
|/ | | | | | | | | | | | | | If one deletes a media with attachments, there have been various problems: 1) If the file in the storage did not exist any more (maybe because due to a previous deletion attempt?), the error propagation failed, because the wrong thing was gathered. 2) The attachment database entries were not deleted. Using cascade for this, for now. Also add a simple unit test, that tests both by having a broken attachment on a media.
* Use system wide EXIF package, if available.Elrond2013-02-071-1/+5
| | | | | | Created and tested by Simon Fondrie-Teitler. Thanks!
* Improve formatting for hook template docs.Elrond2013-01-311-1/+8
|
* Switching set syntax to python2.6 compatibleChristopher Allan Webber2013-01-311-1/+1
|
* Even better documentation for get_hook_templates!Christopher Allan Webber2013-01-301-1/+9
| | | | Tells how you *can* use it in templates if you really like.
* Improved documentation for get_hook_templates, noting the template tagChristopher Allan Webber2013-01-301-0/+9
|
* Moved the docstring for the plugin template stuff from the class to module ↵Christopher Allan Webber2013-01-301-13/+19
| | | | method
* No need for an __init__ at all in the TemplateHookExtension, really.Christopher Allan Webber2013-01-301-4/+1
|
* Move template hook over to a template_hook tag. Seems to work! :)Christopher Allan Webber2013-01-301-1/+37
|
* Geolocation stuff, including including templates seems to be working-ishChristopher Allan Webber2013-01-302-1/+12
| | | | | | | - I'm having trouble seeing if the geolocation stuff actually works, but plugins are included - including a list of template hooks works, however the macro to include them does not, so it's kinda verbose
* Very start of plugin hooks and openstreetmap pluginificationChristopher Allan Webber2013-01-301-0/+27
| | | | | | | | - Added start of template hook code to pluginapi.py - Started to break openstreetmap into plugin; moved templates - Added plugin hooks in media and image media templates ... almost certainly, none of this works yet. :)
* Better Py3 compat: d.has_key(k) -> k in dElrond2013-01-303-4/+3
| | | | | | | | py3 does not have dict.has_key any more. You have to use "key in dict" instead. As that works in python2 as well, let's use that. Also some small bits of pep8.
* Merge branch '216_cwebber_style_unique_slugs'Christopher Allan Webber2013-01-251-1/+1
|\
| * Disallow ":" as part of a media slugSebastian Spaeth2013-01-151-1/+1
| | | | | | | | | | | | | | We might want to use "id:IDN" as a special case slug to point to a media's id. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Normalize the email address in the same way in all placesSebastian Spaeth2013-01-211-0/+13
| | | | | | | | | | | | | | | | | | We were case normalizing the email address for registration, but not at all for the forgotten password retrieval. Make a tools.mail.normalize_email helper that can be used to normalize the email in the same way in all places. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* | Move workbench into tools directory.Elrond2013-01-171-0/+164
|/
* 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>