25 Commits

Author SHA1 Message Date
Elrond
e6bd03d429 Doc string for ProcessingState. 2013-04-22 22:18:24 +02:00
Elrond
e8676fa383 MediaManager: Use .foo instead of ['foo'].
To make .media_fetch_order work, create a property.
2013-04-17 12:08:53 +02:00
Elrond
8ec87dc3fd Implement queue dir delete for proc_state.delete_queue_file
Implement queue dir deleting in the
proc_state.delete_queue_file helper function.
2013-04-08 16:12:32 +02:00
Elrond
d9f61cf7d7 Create ProcessingState.store_public.
The ideas is by Alon Levy.

Use it in ProcessingState.copy_original for now.
2013-04-03 18:52:17 +02:00
Elrond
fb46fa663d Kill monkeypatching of ProcessingState.
And change the process_foo() API to accept a
processingstate now.

image and video are tested, the others are UNTESTED.
2013-02-08 10:09:37 +01:00
Elrond
715ea49546 Also refactor "copy original into public storage".
This makes the processing code easier to read/write and
alos will help the reprocessing once we get to it.

Thanks to Joar Wandborg for testing!
2013-02-08 10:09:37 +01:00
Elrond
e382792637 ProcessingState: Document monkey patching. 2013-02-08 10:09:37 +01:00
Elrond
93b14fc300 Implement ProcessingState class and use for images
The idea is to have a class that has the knowledge of the
currently being processed media and also has tools for
that.

The long term idea is to make reprocessing easier by for
example hiding the way the original comes into the
processing code.
2013-02-08 10:05:42 +01:00
Sebastian Spaeth
c7b3d070b6 Don't pass request into run_process_media
People(tm) want to start run_process_media from the CLI and might not
have a request object handy. So pass in the feed_url into
run_process_media rather than the request object and allow the feed url
to be empty (resulting in no PuSH notification at all then).

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 15:03:00 +01:00
Sebastian Spaeth
2cfffd5ed8 Make PuSHing the Pubhubsubbub server an async task (#436, #585)
Notifying the PuSH servers had 3 problems. 

1) it was done immediately after sending of the processing task to celery. So if celery was run in a separate
process we would notify the PuSH servers before the new media was processed/
visible. (#436)

2) Notification code was called in submit/views.py, so submitting via the
   API never resulted in notifications. (#585)

3) If Notifying the PuSH server failed, we would never retry.

The solution was to make the PuSH notification an asynchronous subtask. This
way: 1) it will only be called once async processing has finished, 2) it
is in the main processing code path, so even API calls will result in
notifications, and 3) We retry 3 times in case of failure before giving up.
If the server is in a separate process, we will wait 3x 2 minutes before
retrying the notification.

The only downside is that the celery server needs to have access to the internet
to ping the PuSH server. If that is a problem, we need to make the task belong
to a special group of celery servers that has access to the internet.

As a side effect, I believe I removed the limitation that prevented us from
upgrading celery.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 14:53:08 +01:00
Sebastian Spaeth
b0c8328e54 Move db.sql.models* to db.models* 2013-01-07 11:44:29 +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
5c2b84869f Move DBModel._id -> DBModel.id
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>
2012-12-21 00:30:48 +01:00
Christopher Allan Webber
6af6bc05bb We don't need to save entries during processing... also adding comments explaining such 2012-12-12 10:14:24 -06:00
Sebastian Spaeth
5f8b4ae895 make media_manager a property of MediaEntry in mixin.py
In all cases where get_media_manager(_media_type_as_string) was called in
our code base we ultimately passed in a "MediaEntry().media_type" to get
the matching MEDIA_MANAGER. It so makes sense to make this a function of
the MediaEntry rather than a global function in mediagoblin.media_types and
passing around media_entry.media_type as arguments all the time.

It saves a few import statements and arguments. I also made it so the
Media_manager property is cached for subsequent calls, although I am not too
sure that this is needed (there are other cases for which this would make
more sense)

Also add a get_media_manager test to the media submission tests. It submits
an image and checks that both media.media_type and media.media_manager
return the right thing. Not sure if these tests could not be merged with an
existing submission test, but it can't hurt to have things explicit.

TODO: Right now we iterate through all existing media_managers to find the
right one based on the string of its module name. This should be made a simple
dict lookup to avoid all the extra work.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-04 15:15:41 +01:00
Joar Wandborg
939d57a022 HTTP callback fixes
- 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.
2012-09-26 23:53:51 +02:00
Joar Wandborg
5354f954dc Added support for http callbacks on processing
Sends an HTTP POST request back to an URL given on submission to the API
submit view.
2012-09-26 23:53:51 +02:00
Joar Wandborg
2891b2c6d0 All processing exceptions are now logged
All processing exceptions should now be logged, the MediaEntry marked as
failed, the exception re-raised.
2012-08-01 01:16:00 +02:00
Joar Wandborg
6471291575 Panel improvements
- Added progress meter for video and audio media types.
- Changed the __repr__ method of a MediaEntry to display a bit more
  useful explanation.
- Added a new MediaEntry.state, 'processing', which means that the task
  is running the processor on the item currently.
- Fixed some PEP8 issues in user_pages/views.py
- Fixed the ATOM TAG URI to show the correct year.
2012-07-11 00:36:42 +02:00
Joar Wandborg
51eb0267d9 Minor improvements to the processing panel
- It is now possible to actually see what's processing, due to a bug fix
  where __getitem__ was called on the db model.
- Removed DEPRECATED message from the docstring, it wasn't true.
2012-07-10 18:13:02 +02:00
Brett Smith
5bd0adebd0 Prevent non-Unicode SQLAlchemy warnings in most submission tests.
This commit  makes test_submission mostly warning-clean.
2012-07-08 10:04:06 -04:00
Joar Wandborg
deea3f6661 Merge remote-tracking branch 'joar/audio+sniffing'
Conflicts:
	mediagoblin/media_types/image/processing.py
	mediagoblin/media_types/video/__init__.py
	mediagoblin/media_types/video/processing.py
	mediagoblin/tests/test_submission.py
2012-03-27 12:05:09 +02:00
Brett Smith
c16b819663 Merge remote branch 'origin/master' into bug261-resized-filenames
This merge involved moving the new FilenameBuilder class to
processing/__init__.py, and putting the comment deletion tests back into
test_submission.py using the refactored functions.
2012-03-26 14:10:22 -04:00
Elrond
eace050a7d Move celery task into own task.py
Move the actual celery task from processing/__init__.py
into its own .../task.py. That way it can be imported as
needed.
2012-03-21 12:12:07 +01:00
Elrond
4bdee988b6 Turn processing.py into a submodule.
processing.py -> processing/__init__.py

This is in preparation for splitting processing a bit.
The main reason for the split is celery setup: celery needs
to be setup before even importing and importing and
subclassing some of its parts. So it's better to move the
critical parts into their own submodule and import it as
late as needed.
2012-03-21 12:11:58 +01:00