[web2py] web2py (context process , midelware)

2011-07-20 Thread ariel.glez.m
what thing replace in web2py the context process and midelware of
django.


[web2py] json call

2011-07-05 Thread ariel.glez.m
I have this code, in the initial view shows the elements of the table
service with a json call, i want whenever insert a new element in the
form of form.html view (the view form.html is a popup window) re-make
the json call and refresh the initial view, i tried several variations
and all have failed me, anyone have a similar example??? or any
idea???

db.define_table('service',
   Field('name'))

controller.py

def index():
   return dict()

def form():
 
form=FORM(INPUT(_name='name',requires=IS_NOT_EMPTY()),INPUT(_type='submit'))

   if form.accepts(request.vars, session):
  db.service.insert(name = form.vars.name)
   return dict(form=form)


@service.json
def hello():
   l = []
   for row in db(db.service.id  0).select():
 l.append(row.name)
   return l

//---

index.html..

{{extend 'layout.html'}}

label class='link' style='color:green'+/label

div id='target'

/div

script
jQuery('.link').click(function(){popup({{=URL(r=request,
f='form')}})});

jQuery.getJSON({{=URL(r=request,f='call',args=['json','hello'])}},
   function(msg){
  jQuery.each(msg, function(){ jQuery(#target).append(this
+ br /); } )
   }
 );


/script

form.html

{{extend 'layout.html'}}
{{=form}


[web2py] example celery integration?

2011-06-27 Thread ariel.glez.m
someone have a example where integrate web2py and celery???


[web2py] LOAD() ajax problem

2010-10-14 Thread ariel.glez.m
Hi everyone, I'm new here , sorry for the english
 already made what facebook do with comments, everything works fine,
but i'm having an issue that worried me. Sometimes the submit fails
with secondary comments, it doesn't send anything to the controller,
but when you try again it works fine, i'm using the LOAD()
functionperhaps is a validation issue or a framework problem with
ajax LOAD() function...not sure...here is the code:

db.define_table('comment',
   Field('body',label='Comment'))


db.define_table('comment2',
   Field('body',label='Comment'),
   Field('idcomentario',db.comment))


db.comment.body.requires=IS_NOT_EMPTY()
db.comment2.body.requires=IS_NOT_EMPTY()
db.comment2.idcomentario.writable = db.comment2.idcomentario.readable
= False

/


def index():

form = SQLFORM(db.comment,fields=['body'])
if form.accepts(request.vars,session):
response.flash='OK'

lista = db(db.comment.id0).select()

return dict(form=form,lista=lista)

def post():

comentario=db(db.comment.id==request.args[0]).select()[0]
form = SQLFORM(db.comment2,fields=['body'])
form.vars.idcomentario=comentario.id

if form.accepts(request.vars,session):
 response.flash='OK'

comments=db(db.comment2.idcomentario==comentario.id).select()

return dict(form=form,comments=comments)

//
index.html
{{extend 'layout.html'}}
h2Postea un comentario:/h2

{{=form}}

{{if len(lista):}}
{{for elem in lista:}}
 h3{{=elem.body}}/h3
 {{=LOAD('default','post.load',args=[elem.id],ajax=True)}}
 {{pass}}
{{else:}}

{{pass}}



post.html

{{extend 'layout.html'}}

{{if len(comments):}}
{{for comment in comments:}}
   h5{{=comment.body}}/h5
{{pass}}
{{else:}}
{{pass}}

{{=form}}

///
post.load

{{if len(comments):}}
{{for comment in comments:}}
   h5{{=comment.body}}/h5
{{pass}}
{{else:}}
{{pass}}

{{=form}}