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

  • Home
  • SEARCH
  • 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 8149331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:49:45+00:00 2026-06-06T14:49:45+00:00

I am using Mako templates to create a web page. There is a section

  • 0

I am using Mako templates to create a web page.

There is a section in which I prevent html escaping using | n. However, inside, I also need to show some user generated entries for which I need to escape the HTML on the view side of the apps.

What is the way to go with Pyramid for this?

I know there is CGI escaping but it does not seem as good as Mako’s own and I would like to use that.

currently I have:

from pyramid.compat import escape

escape(str)

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-06-06T14:49:46+00:00Added an answer on June 6, 2026 at 2:49 pm

    According to the pyramid docs, pyramid.compat.escape provides cgi.escape (html.escape on Python 3).

    According to the mako docs, the escape functionality is provided by markupsafe.escape(x). One thing to keep in mind that might be helpful is that MarkupSafe will look for an __html__ method on the object it is escaping, and if it finds it, it will call that method and use the results as the escaped string. This might allow you some flexibility in how certain items are escaped.

    You can either use one of these, or another option is (if possible) to change your template so that the escaping actually does happen in the template rather than the view.

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

Sidebar

Related Questions

I am using Mako to create some configuration templates for network routers. I would
I'm using CherryPy, Mako templates, and SQLAlchemy in a web app. I'm coming from
I'm working on a Pyramid project using Mako templates, and I'm trying to display
Using android 2.3.3, I have a background Service which has a socket connection. There's
I'm using Pylons with Mako templates and I want to avoid typing this all
I'm using Mako's inheritance features to factor out common page elements, like a header
Using WebViewBrush I can render web page content (it's screen shot) to e.g. Rectangle
I'm using mako templates to generate specialized config files. Some of these files contain
I frequently encounter this error in Mako templates using Pylons 0.9.7: AttributeError: 'NoneType' object
Im curious as to why this happens. Im using Mako templates to iterate over

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.