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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:46:58+00:00 2026-05-29T17:46:58+00:00

I defined a method for rendering pages: def doRender(handler, tname=’index.html’,values = {}): temp =

  • 0

I defined a method for rendering pages:

def doRender(handler, tname='index.html',values = {}):
    temp = os.path.join(os.path.dirname(__file__),
                        'templates/'+tname)
    if not os.path.isfile(temp):
        return False

    newval = dict(values)
    newval['path'] = handler.request.path

    user = users.get_current_user()
    url = users.create_login_url(handler.request.uri)
    url_linktext = 'Login'

    if user:
        url = users.create_logout_url(handler.request.uri)
        url_linktext = 'Logout'

    newval['user'] = user
    newval['url'] = url
    newval['url_linktext'] = url_linktext

    outstr = template.render(temp, newval)
    handler.response.out.write(outstr)
    return True

Also, I have these classes:

GruposHandler

class GruposHandler(webapp.RequestHandler):    
    def get(self):
        self.obtenerPagina()

    def obtenerPagina(self, pOpcion = None, pMensajeInformacion = None):
        opcion = pOpcion if pOpcion is not None else self.request.get('opcion') 
        usuario = obtenerUsuario()
        rsGrupos = obtenerGruposAll()
        listaGruposCreadosPorUsuario = []
        #
        #

        for grupo in rsGrupos: 
            if grupo.creadoPorUsuario == usuario:
                listaGruposCreadosPorUsuario.append(grupo)

        blahh...

        if opcion == 'gruposMios':
            doRender(self, 'grupos_mios.html', {'listaGruposCreadosPorUsuario':listaGruposCreadosPorUsuario,
                                                'informacion':pMensajeInformacion})

NuevoGrupoHandler

class NuevoGrupoHandler(webapp.RequestHandler):
    def post(self):
        nombre = self.request.get('nombre')
        descripcion = self.request.get('descripcion')

        #comprobar que no exista un grupo con el mismo nombre
        obj = Grupo.get_by_key_name(nombre)
        if obj:
            doRender(self, 'nuevo_grupo.html', {'mensaje_descripcion':'Ya existe un grupo con ese nombre.'})
        else:
            grupo = model.Grupo(key_name = nombre, nombre=nombre, descripcion = descripcion);
            grupo.put()
            grupoHandler = GruposHandler()
            grupoHandler.obtenerPagina("gruposMios", 'Informacion: un nuevo grupo fue agregado.')

When webapp receive an HTTP GET request to the URL /nuevogrupo, it instantiates the NuevoGrupoHandler class and calls the instance’s get method.
So at this point, everything works as expected

def main():
    application = webapp.WSGIApplication([
                                          ('/nuevogrupo', NuevoGrupoHandler),
                                          etc...

but when I call method GruposHandler.obtenerPagina() from NuevoGrupoHandler.post(), when the method doRender() inside obtenerPagina()
is reached, an exception is thrown at this line:

newval['path'] = handler.request.path

This is the stacktrace I’m getting:

AttributeError: ‘GruposHandler’ object has no attribute ‘request’

So it seems that something is not properly setted when it is not called from the webapp.WSGIApplication instance. I’m not so sure.

Sorry I could not explain the problem better.

What should I do to avoid that exception.

Thanks in advance.

  • 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-29T17:47:03+00:00Added an answer on May 29, 2026 at 5:47 pm

    I don’t know about google-app-engine, but the issue is from your side, not from the WSGIApplication.

    In NuevoGrupoHandler.post method, you’re instanciate a new GruposHandler(), that you use for rendering. And this instance doesn’t have request attribute, that cause your exception.

    My approach would be to copy the request attribute from your current instance to the new one:

    grupoHandler = GruposHandler()
    grupoHandler.request = self.request # <<< add this
    grupoHandler.response = self.response # <<< and this
    grupoHandler.obtenerPagina("gruposMios", 'Informacion: un nuevo grupo fue agregado.')
    

    Then your new instance handler will have the same request as the current one, and the exception will be avoided.

    Edit:

    By the way, if you want to just use an external method like this, it would be better to create another baseclass that implement the doRender, and inherit from it for GruposHandler and NuevoGrupoHandler:

    class RenderRequestHandler(webapp.RequestHandler):
        def obtenerPagina(self, ...):
            pass
    
        def do_render(self):
            pass
    
    class GruposHandler(RenderRequestHandler):
        pass
    
    class NuevoGrupoHandler(RenderRequestHandler):
        pass
    

    And implement both method in the baseclass. 🙂

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

Sidebar

Related Questions

I have a method defined in ApplicationController : def some_checking ... end And I
why defined extension method with UrlHelper don't added in Url. EXTENSIONMETHOD when i want
I have a method defined in IDL as follows : interface IMyFunc : IDispatch
Here's my problem: I have a virtual method defined in a .h file that
i am trying to call a navite method defined in c++ from java, the
I'm getting a NoMethodError when trying to access a method defined in one of
i have a code like this i have defined the method goNext but still
Is there any method / API defined to collect system info in osx. I
Duplicate: How To Find Where A Ruby Method Is Defined At Runtime With a
I would like to pass an argument(s) to a method being defined using define_method,

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.