I think this should be a simple question to answer.
I have the next classes:
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()
listaOtrosGrupos = []
listaGruposSuscriptos = []
blah blah ........
class NuevoGrupoHandler(webapp.RequestHandler):
def post(self):
nombre = self.request.get('nombre')
descripcion = self.request.get('descripcion')
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.')
but it seems that method obtenerPagina from GruposHandler is not being called properly. This is the stacktrace I get:
TypeError: unbound method obtenerPagina() must be called with GruposHandler instance as first argument (got str instance instead)
What I’m doing wrong?
Thanks in advance…
==>
UPDATE:
GruposHandler.obtenerPagina()method accepts 3 arguments:self,pOpcion=NoneandpMensajeInformacion=None.Since 2 of them are optional, you don’t get:
when calling it like this:
Instead
GruposHandler.obtenerPagina()interprets arguments like this:and raises:
To get rid of the exception, you need to call this method from instance:
and
selfwill be passed toobtenerPaginaimplicitly.