Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:58:52+00:00 2026-05-30T00:58:52+00:00

I want to resolve a status 405 that I get from the task queue

  • 0

I want to resolve a status 405 that I get from the task queue when trying to generate a report:

2012-02-16 03:56:53.012 /report/ 405 3ms 0kb AppEngine-Google; (+http://code.google.com/appengine)

2012-02-16 03:56:53.007 /createreport/ 302 20ms 0kb Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20100101 Firefox/4.0
I 2012-02-16 03:56:52.990 creating report task

The code that creates the task is

class CreateReportHandler(webapp2.RequestHandler):

    def get(self):
        logging.info('creating report task')
        taskqueue.add(url=r'/report/')
        self.redirect('/')

and I have it routed with webapp2:

Route(r'/createreport/', handler=CreateReportHandler, name='createreport'),

then I should be able to make it a cron job but when I test it I get a 405 from the access of this code which times out if I try to run it directly:

class Report(webapp2.RequestHandler):

    def get(self):
        # Create a conversion request from HTML to PDF.
        users = User.query()
        today = date.today()
        startdate = date(today.year, today.month, 1) # first day of month   
        html = None     
        for user in users: 
            if user.activity() > 0:
                logging.info('found active user %s %s' % (user.firstname, user.lastname))
                html = '<html><body><table border="1">'
                html = html + '<tr><td>ORDER</td><td colspan="2">----DISTRIBUTOR----</td><td>ORDER</td><td>Silver</td><td>%</td><td>Total</td><td>Bonus</td></tr>'
                level = user.level()
                distributor = user
                while distributor.has_downline():
                    downline = User.query(User.sponsor == distributor.key).order(User.lastname).fetch()
                    for person in downline:  # to this for whole downline
                        orders = model.Order.all().filter('distributor_id =' , person.key.id()).filter('created >' , startdate).filter('status =', 'PAID').fetch(999999)
                        silver = 0
                        name = person.firstname +' '+ person.lastname
                        for order in orders:
                            logging.info('found orders')
                            for idx,item in enumerate(order.items):
                                purchase = model.Item.get_by_id(long(item.id()))
                                amount = int(order.amounts[idx])
                                silver = silver + amount*purchase.silver/1000.000 
                            if len(name) > 13:
                                name = name[13]
                            html = html + '<tr><td>' + str(order.created.date().day)+'/'+ str(order.created.date().month )+'</td><td>' + filters.makeid(person.key.id()) +'</td><td>' + name + '</td><td>' + str(order.key().id()) + '</td><td>' + str(silver) 
                            dist_level = order.dist_level
                            bonus = 0   
                            if level == 5 and dist_level == 4:                          
                                bonus = 0.05
                            if level == 5 and dist_level == 3:
                                bonus = 0.1
                            if level == 5 and dist_level == 2:
                                bonus = 0.13
                            if level == 5 and dist_level == 1:
                                bonus = 0.35

                            if level == 4 and dist_level == 3:                          
                                bonus = 0.05
                            if level == 4 and dist_level == 2:
                                bonus = 0.08
                            if level == 4 and dist_level == 1:
                                bonus = 0.3

                            if level == 3 and dist_level == 2:                          
                                bonus = 0.03
                            if level == 3 and dist_level == 1:
                                bonus = 0.25

                            if level == 2 and dist_level == 1:                          
                                bonus = 0.2

                            html = html + '</td><td>' + str(bonus) + '</td><td>' + str(order.total)
                            bonusmoney = bonus * float(order.total)
                            html = html + '</td><td>' + str(bonusmoney) + '</td></tr>'

                        distributor = person

                html = html + '</table>'

            asset = conversion.Asset("text/html", html, "test.html")
            conversion_obj = conversion.Conversion(asset, "application/pdf")        
            rpc = conversion.create_rpc()
            conversion.make_convert_call(rpc, conversion_obj)

            result = rpc.get_result()
            if result.assets:
                for asset in result.assets:
                    logging.info('emailing report')# to %s' % user.email)
                    message = mail.EmailMessage(sender='noreply@bnano.se',
                                    subject='Report %s %s' % (user.firstname, user.lastname))
                    message.body = 'Here is the monthly report'
                    message.to = 'niklasro@gmail.com'
                    message.bcc = 'fridge@koolbusiness.com'
                    message.attachments = ['report.pdf', asset.data]
                    message.send()
                    logging.info('message sent')

How can I resolve the status 405 and get through the execution?

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:58:54+00:00Added an answer on May 30, 2026 at 12:58 am

    I came from GAE/J-land, so I am not familiar with Python, but I had encountered 405 response from my taskqueue worker before. In my case, it is caused due to setting the TaskOption method to POST while building the Task, while my handler only serves GET requests.

    EDIT: After checking the TaskQueue.add() docs, it appears that the default method used if the method is not specified (as in your code example) is POST, while your handler appear to only able to serve GET requests.

    My suggestion would be explicitly specify that your task uses GET method instead of POST, or change the handled method of your handler into POST instead of GET.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to Resolve ~/whatever from inside non-Page contexts such as Global.asax (HttpApplication), HttpModule,
I want to have a rake task that reads a HAML file and creates
I have this issue that I want to resolve. Lets think we have this
I have a class with internal constructor and want to Resolve it from Unity
I want to resolve in Windsor a series of classes that implement this interface:
I want to parse the following XML document to resolve all entities in it:
I have some code that uses an Informix 11.5 database that I want to
I'm writing a class library that will offer some asynchronous processing, and want to
I want to emit a method that returns a Func<>. Inside this method I
I want to watch a system setting and get notified when its value changes.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.