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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:14:19+00:00 2026-06-05T19:14:19+00:00

I am new to pyramid. I use python2.7, MSSQL, slqalchemy.mssql and use the gbk

  • 0

I am new to pyramid. I use python2.7, MSSQL, slqalchemy.mssql and use the gbk charset, and I have much old data. So I change the front html to encode to gbk, using the following code:

@view_config(route_name='g', renderer='json')
def my_view1(request):
  print 2
  print request.charset
  print 1
  print isinstance(request.params['one'], str)
  if request.params['one']:
    print request.params['one']
    filters = (Bzjl.one == request.params['one'])
  try:
    two1 = DBSession.query(Bzjl).filter(filters)
  except DBAPIError:
    return Response(conn_err_msg, content_type='text/plain', status_int=500)
  return Response(getjson(two1))

example url: http://127.0.0.1:6543/g?one='中国福建' returns no rows: {"records": 0, "total": 20, "rows": [], "page": 1}

  • 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-05T19:14:21+00:00Added an answer on June 5, 2026 at 7:14 pm

    Pyramid supports a request factory. You can use this to decode the request.

    def request_factory(environ):
        req = pyramid.request.Request(environ)
        return req.decode(charset='gbk')
    
    config.set_request_factory(request_factory)
    

    This means that the request passed around within pyramid will be using the gbk charset. Failure to decode the request with this charset will cause UnicodeDecodeError exceptions so you may want to add extra logic to your request factory to handle these things.

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

Sidebar

Related Questions

I am new to python and Pyramid. I have installed pyramid today and i
I'm new to pyramid as well as the traversal concept. I have a basic
New to FluentNHibernate =D I have a parent/children classes as follows: public class Parent
NEW EDIT: I have narrowed my problem to this - i have a view
New to Git and just started to use Github. Just created my first public
we include an iFrame inside a pyramid webpage. The iFrame is a local html
I have a database table (called Info) that stores [Data], [fkID], [UserID], [Timestamp]. [Data]
New to Applets, I have never dealt with having to export the resources to
For a new (Python) web application with the Pyramid web framework, I'd like to
I'm building an app on Pyramid framework and would like to use the web2py-DAL

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.