python - Can't make categories in my webpy blog, bad default value use, using browser direction bar input like alias -


i'm trying make categories in self-developed blog webpy try make :

mywebpage.com/c/categoriename

be input shows categorie (like alias ?¿?)

 urls = (        '/c/(.*)','index' ) 

then index class is:

class index(object):     def get(self,cat):         seleccion = functions.categoria(db,cat)         #seleccion = db.select('contenido',what="*",order="modificado desc")         #print seleccion         return render.index(seleccion.getthread(),cat) 

i have .py document helping functions:

class categoria(object):     def __init__(self,datab,nombre='frutas'):         '''         selecciona y asigna una lista o diccionario         con el contenido de la base de datos dispuesto en         objetos de la clase noticias.         '''         self.datab = datab #objeto database         self.nombre = nombre #cadena con el nombre de la categoria         self.n = self.getcat() #calculo del numero de la categoria problemas         self.thread = self.getthread()              def getcat(self):         ''' returns categorie number stored in database         '''         = self.datab.select('categorias',where='catname = $nombre', vars=dict(nombre=self.nombre))         return a[0].catid      def getthread(self):         myvars = dict(numero= '%'+str(self.n)+'%' )         d = self.datab.query("select * contenido category $numero", vars= myvars)         #what="contenttitle,content,'update'",         return d      # db.query("select * foo x = $x", vars=dict(x='f'), _test=false)      def __str__(self):         'some more code, doesn't matter' 

i have mysql database correctly configured , contains sample content. try run usin feature best result take place default value variable cat doesn't let me change category in view browsers direction feature.

thank much.

perhaps problem result of seleccion.getthread call.

in webpy db.query returns web.iterbetter can iterate once. may try return d.list() instead of d, convert web.iterbetter list.

upd: perhaps didn't understand question, try:

'/c/(.*)','index' mapping means category can empty, either set default value in function this: def get(self,cat=none): or change mapping '/c/(.+)','index' not work '/c/' request path.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -