[google-appengine] Using Google App Engine Queues service with Django

2011-01-26 Thread Mario César
Hello all,

I am trying to use Google App Engine queues API, and I am having
problems with this. It seems that in some part of the process the CSRF
it's not working or it's getting problems with the api.

as I understand the api executes the task calling the url and making
and http request in background.

The complete url is the API is calling is →
http://localhost.localdomain:8000/admin/cooking/recipe/36/chefworker/

When it raises this exception:

Traceback (most recent call last):
  File "/home/mariocesar/Proyectos/Cooking/cooking/django/core/
handlers/base.py", line 100, in get_response
response = callback(request, *callback_args,
**callback_kwargs)
  File "/home/mariocesar/Proyectos/Cooking/cooking/django/views/
decorators/csrf.py", line 24, in wrapped_view
resp.csrf_exempt = True
AttributeError: 'NoneType' object has no attribute 'csrf_exempt'

So, the csrf middleware, the cookie, some data or the response itself
is missing from the request that the GAE api makes to execute the task
in the background.

How to solve this without disabling CSRF on Django? however, it's
posible to have views for workers using  djangoappengine at all?

Down are the models.py and admin.py files I am using.

**models.py**

from django.db import models

class Recipe(models.Model):
name = models.CharField(max_length=140)
description = models.TextField()
cooking_time = models.PositiveIntegerField()
status = models.CharField(max_length=40)

def __unicode__(self):
return self.name

def cookthis(self):
import time
self.status = 'The chef is cooking this recipe'
self.save()
time.sleep(obj.cooking_time)
self.status = 'It\'s done ! the recipe is ready to serve'
self.save()

**admin.py**

import logging

from django.contrib import admin, messages
from django.http import HttpResponse
from django.utils.functional import update_wrapper
from django.contrib.admin.util import unquote
from django.shortcuts import get_object_or_404, render_to_response
from django import template
from django.core.urlresolvers import reverse
from google.appengine.api import taskqueue
from google.appengine.api.taskqueue import TaskAlreadyExistsError

from cooking.models import Recipe
from django.views.decorators.csrf import csrf_exempt

class AdminRecipe(admin.ModelAdmin):
def get_urls(self):
from django.conf.urls.defaults import patterns, url

def wrap(view):
def wrapper(*args, **kwargs):
return self.admin_site.admin_view(view)(*args,
**kwargs)
return update_wrapper(wrapper, view)

info = self.model._meta.app_label,
self.model._meta.module_name

urlpatterns = super(AdminRecipe, self).get_urls()
myurls = patterns('',
url(r'^(.+)/cook/$',
wrap(self.cook_view),
name='%s_%s_chefworker' % info),
url(r'^(.+)/chefworker/$',
wrap(self.chefworker_worker),
name='%s_%s_chefworker' % info),
)
return myurls + urlpatterns

def cook_view(self, request, object_id, extra_context=None):
obj = get_object_or_404(Recipe, pk=unquote(object_id))
if request.POST:
try:
taskqueue.add(
name="recipie-%s" % obj.id,
url=reverse('admin:cooking_recipe_chefworker',
args=(obj.id,))
)
messages.add_message(request, messages.INFO, 'Chef
is cooking the recipe.')
except TaskAlreadyExistsError:
messages.add_message(request, messages.ERROR,
'chef is already cooking that recipe.')

context_instance = template.RequestContext(request,
current_app=self.admin_site.name)
return render_to_response("admin/cooking/recipe/
cook_view.html", {'object': obj}, context_instance=context_instance)

#TODO: Add csrf token on form
@csrf_exempt
def chefworker_worker(self, request, object_id,
extra_context=None):
import time

if request.POST:
obj = get_object_or_404(Recipe, pk=unquote(object_id))
obj.cookthis()

return HttpResponse('done')

admin.site.register(Recipe, AdminRecipe)


A VERY IMPORTANT NOTE:
Was hard to debug this error, cause the dev_appserver logger was just
raising 403 errors, no other info; so, I have to patch the file google/
appengine/api/taskqueue/taskqueue_stub.py line 574 and add
"logging.info('response --- \n%s' % result)" to get the output of the
exceptions.

I would appreciate any help

Best Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to thi

[google-appengine] I am unable to add an existing appengine app to a google apps Domain, why?

2011-02-22 Thread Mario César
Hello all,

I am having strange problems trying to add a google app engine app to
google apps. I hope someone could give me a hint about solving this.

I would try to be very descriptive, the issues is obscure for me, so I
would give all details:

Using  a gmail account I create an app on googleappengine named
"venabolivia" later the ownership was given to
marioce...@venabolivia.com an admin account for the domain.

So, I am the owner of the venabolivia app on googleappengine with my
account marioce...@venabolivia.com, also the admin of the domain
venabolivia.com.

When I try to add the google app service with the app to the domain it
raises the error "You do not have the permissions necessary to install
this application."

How can it be, If I a owner of the app and admin of the domain?

Trying to add from the domain cpanel or from the appengine dasboard
raises the same error.

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: I am unable to add an existing appengine app to a google apps Domain, why?

2011-02-22 Thread Mario César
Thank you Brandon,

But, it doesn't work I even clear all the cache and start from scratch
with no cookies and sign in with just the google app admin account.

I just get the error "You do not have the permissions necessary to
install this application."

I think the problem was create the app with a gmail account, I create
apps with the google app admin account like venabolivia-testing, and I
can add this with no problems, and not the first I create
'venabolivia' ... This is so obscure to me, Why something so simple as
change owners is not working, specially for that google dashboard
shows me as owner ! if I am owner why I don't have
permission??? ... :'(

I wan to keep the name of the app, so it's frustating. I Think I would
have to delete the app and create again with the google app admin
account. I don't know ...


On 22 feb, 11:34, branflake2267  wrote:
> Hi,
> I had the same problem when I added a domain to my project. I signed out of
> my gmail accounts I think to get it to work.. The google sign in process
> gets confused with account signed in, at least thats what I thought.
>
> Try signing out of the accounts except for google app engine dashboard.
>
> Brandon Donnelsonhttp://gwt-examples.googlecode.com

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] 'The 3000 limit' Guido has change the ticket status from accepted to started

2011-08-16 Thread Mario César

I have goose bumps.

→ http://code.google.com/p/googleappengine/issues/detail?id=4639#c17

-- Mario César

--
You received this message because you are subscribed to the Google Groups "Google 
App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.