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 7718391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:09:24+00:00 2026-06-01T03:09:24+00:00

I am using Pyramid 1.3 with the AppEngine 1.6.4 SDK on OS X 10.7.3.

  • 0

I am using Pyramid 1.3 with the AppEngine 1.6.4 SDK on OS X 10.7.3. I am using Python 2.7 and have threadsafe true in app.yaml.

@view_config(route_name='manager_swms', permission='manager', renderer='manager/swms.jinja2')
def manager_swms(request):
    """Generates blobstore url and passes users swms in swms table"""

    # generate url for any form upload that may occur
    upload_url = blobstore.create_upload_url('/upload_swm')

    user = get_current_user(request)
    swms = DBSession.query(SWMS).filter_by(owner_id=int(user.id)).all()

    return {
        "analytics_id": analytics_id,
        "user": get_current_user(request),
        "upload_url": upload_url,
        "swms": [(x.filename, x.blob_key) for x in swms]
    }

class BlobstoreUploadHandler(object):
    """Base class for creation blob upload handlers."""

    def __init__(self, *args, **kwargs):
        self.__uploads = None

    def get_uploads(self, field_name=None):
        """Get uploads sent to this handler.

        Args:
          field_name: Only select uploads that were sent as a specific field.

        Returns:
          A list of BlobInfo records corresponding to each upload.
          Empty list if there are no blob-info records for field_name.
        """
        if self.__uploads is None:
            self.__uploads = {}
            for key, value in self.request.params.items():
                if isinstance(value, cgi.FieldStorage):
                    if 'blob-key' in value.type_options:
                        self.__uploads.setdefault(key, []).append(
                            blobstore.parse_blob_info(value))

        if field_name:
            try:
                return list(self.__uploads[field_name])
            except KeyError:
                return []
        else:
            results = []
            for uploads in self.__uploads.itervalues():
                results += uploads
            return results

@view_config(route_name='upload_swm', permission='manager')
class UploadHandler(BlobstoreUploadHandler):
    ''' Handles redirects from Blobstore uploads. '''

    def __init__(self, request):
        self.request = request
        super(UploadHandler, self).__init__()

    def __call__(self):

        user = get_current_user(self.request)
        for blob_info in self.get_uploads('file'):

            new_swm = SWMS(
                owner_id = int(user.id),
                blob_key = str(blob_info.key()),
                filename = blob_info.filename,
                size = blob_info.size,
            )
            DBSession.add(new_swm)
        DBSession.flush()

        # redirect to swms page
        return HTTPFound(location='/manager/swms')

In the above code, manager_swms() generates a page which includes a form for uploading a file into the Blobstore. The form works OK and I can see the blob appear in the Blobstore when the form is used. The redirect from the blobstore POST is then to /upload_swm where I successfully take BlobInfo details and place them into a SQL table. All of this is good and the final thing I want to do is redirect to the first page so another file can be uploaded if need be and I can show the list of files uploaded.

As per Pyramid documentation, I am using HTTPFound(location=’/manager/swms’) [the original page URL] to try and redirect however I get:

ERROR    2012-03-29 22:56:38,170 wsgi.py:208] 
Traceback (most recent call last):
  File "/Users/tim/work/OHSPro/var/parts/google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle
    result = handler(self._environ, self._StartResponse)
  File "lib/dist/pyramid/router.py", line 195, in __call__
    foo = response(request.environ, start_response)
  File "lib/dist/pyramid/httpexceptions.py", line 291, in __call__
    foo = Response.__call__(self, environ, start_response)
  File "lib/dist/webob/response.py", line 922, in __call__
    start_response(self.status, headerlist)
  File "/Users/tim/work/OHSPro/var/parts/google_appengine/google/appengine/runtime/wsgi.py", line 150, in _StartResponse
    _GetTypeName(header[1]))
InvalidResponseError: header values must be str, got 'unicode'
INFO     2012-03-29 22:56:38,174 dev_appserver_blobstore.py:408] Upload handler returned 500
INFO     2012-03-29 22:56:38,193 dev_appserver.py:2884] "POST /_ah/upload/ahJkZXZ-cHJvdG8tc2NvaHNwcm9yGwsSFV9fQmxvYlVwbG9hZFNlc3Npb25fXxgTDA HTTP/1.1" 500 -

AppEngine is clearly objecting to unicode in the HTTP header but I’m not doing anything unusual AFAIK. If I drop into pdb and take a look at the HTTPFound object, the headers are:

ResponseHeaders([('Content-Type', 'text/html; charset=UTF-8'), ('Content-Length', '0'), ('Location', '/manager/swms')])

Why would I get a unicode problem from these?

  • 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-06-01T03:09:25+00:00Added an answer on June 1, 2026 at 3:09 am

    so it looks like you are overriding appengine’s supported webob which is 1.1.1 on the 2.7 runtime. And pyramid 1.3 depends on webob>=1.2. This is most likely the problem because it was the Blobstore handler stuff that was keeping the sdk held back at webob==0.9 until SDK 1.6.4 was released.

    FWIW, this problem is expected to be resolved by SDK 1.6.5 (late April). The only reason I know this is because I was trying to get all this crap resolved when the 2.7 runtime was deemed ready for general use, yet the SDK didn’t support it. see this issue for more details.

    If possible, I would suggest running it with pyramid 1.2, I know that works fine on appengine. And Just hold off on moving to 1.3 for a few weeks. 🙂

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

Sidebar

Related Questions

I have deployed a Pyramid app using mod_wsgi. I have setup the python path
I am using latest Pyramid to build a web app. Somehow we have started
I am practicing with Python using Pyramid framework. I created a py, myfuncs.py ,
I am starting a web project in Python, most likely using Django or Pyramid.
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
Configuration of the Task Queue is done in the app.yaml file. There I have:
I have a pyramid project using the formalchemy admin interface. I added the basic
I'm creating the web app using Pyramid-1.2.1 with SQLAlchemy as database backend. Now I
I have a Pyramid application using Beaker Encrypted cookie sessions. I can log a
I'm trying to deploy a Pyramid app using mod_wsgi on Apache. I get IOError:

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.