Edited wiki page through web user interface.
diff --git a/TaskQueueAPI.wiki b/TaskQueueAPI.wiki index 660687c..4af211d 100644 --- a/TaskQueueAPI.wiki +++ b/TaskQueueAPI.wiki
@@ -18,6 +18,7 @@ <Pawel>There is a solution how to iterate thru more than 1000 entities that was presented at Task Queue API Google I/O session [http://www.youtube.com/watch?v=o3TuRs9ANhs (video here)].</Pawel> +<Daniel>Actually I meant that 1000 entities was a problem before Task Queues. Now, it is true, we can have a task which can start another task which continues the job. Previously, we could have simulated tasks in a similar way by requests, if it had been possible to redirect to the same url</Daniel> == Initial design == @@ -27,6 +28,7 @@ <Pawel>Instead of putting it in soc.views.helper I would suggest putting it in soc.logic because it's actually logic that has nothing to do with view. It doesn't even have to be in helper submodule.</Pawel> +<Daniel>OK, I will change it</Daniel> {{{ def startTask(url, context=None, **kwargs) @@ -35,6 +37,7 @@ It adds a new task to the task queue (now it always uses default queue, but it can be easily changed so as to support other queues - if Melange needs them one day). <Pawel>Yes we need to change it to support different queues, we will have more queues for sure.</Pawel> +<Daniel>OK, I will do it</Daniel> Params usage: {{{ url }}} - the relative worker URL for this Task @@ -52,6 +55,7 @@ Now let us say, we want to write code for a new task. Of course we could write completely entire code for each task, but to reduce amount of duplicate code, we may use some decorators. There are currently two types of decorators defined in the views.helpers.decorators module. <Pawel>Maybe we should put all the tasks in soc.tasks instead of soc.views to differenciate them I know that tasks call normal URL so we need to register those urls but I think that from logical point of view it would be better to have tasks in separate module.</Pawel> +<Daniel> You are definitely right! It would be very thoughtful to have separate module just for tasks, but it will require a lot of work, so I will try to create a new module when I have more time. For example, as you mention in one of your next comments, we need to check access before a task is actually started to prevent random people from running them. As long as we have tasks in soc.views module, it is not a problem, because we can use standard methods. There is no point in duplicating code and re-writing the code in soc.tasks module, it has to be done much more wisely:)</Daniel> ==== Standard task decorator ==== @@ -93,6 +97,11 @@ The most important thing is, however, that one can assume that kwargs contains a value for entities. Thus, he or she does not have to worry about how to retrieve data, but only care about what really has to be done. <Pawel>Where are we getting the entities ?</Pawel> +<Daniel> +The entities are retrieved by the decorator and that is why it is transparent to a developer and he or she can focus on actual task. If you take a look at the decorator code, you will see: +{{{entities, next_key = logic.getOneBatchOfData(filter, order, next_key)}}} +and that is why we have to pass logic to the decorator which I do not like, because the one way I know how to pass the logic is by name and import it by __import__. Another way would be to import all logics in the decorators.py file, pass only logic name to the task. Maybe there is a better way for doing it? +</Daniel> In order to use this function, it has to be decorated as a iterative task: @@ -111,6 +120,7 @@ <Pawel>We need to remember that tasks urls need access checks too, we don't want random people to call the url and execute whatever tasks would execute.</Pawel> +<Daniel>The access may be checked now in the same way, we check access for standard urls</Daniel> And that is basically all with adding a new task, but there is one another thing that has to be done: the task has to be somehow started. @@ -146,6 +156,7 @@ }}} <Pawel>It would be nice if you could provide an example that interates thru more than 1000 entities based on Task Queue API example in the video</Pawel> +<Daniel>Actually the example uses this method (which I used before watching Google I/O video:) - it is all done in decorator. There are four things that are worth being mentioned: # Final url is generated by applying concrete values to the url. @@ -171,9 +182,10 @@ <Pawel>No I don't think there is any documentation for that yet, since Task Queue API is still an App Engine Labs API.</Pawel> - * As far as I know, the Tasks Queues cannot be tested on localhost instances (am I wrong?) + * The tasks can be also tested locally on SDK. They have to be manually run from Admin Console. -<Pawel>You are wrong :-) but you already know that (discussion on IRC). The Tasks can be manually run from Admin Console locally.</Pawel> +<Pawel>You are wrong :-) but you already know that (discussion on IRC). The Tasks can be manually run from Admin Console locally. It has even more options, because tasks may be removed from queues.</Pawel> +<Daniel>Updated :-)</Daniel> * Task Queue API is still under development, so there may be some changes when it is finally released.