Very probability, because i very new in web applications and python

In the past,1 week ago, before we updated version of web2py, we
created 10589 registers with the same application. And now, the only
idea that i have, it is this, the new version of web2py.

This are the controllers involved when we created one register

#Beneficiarios
@auth.requires_login()
def update_benef(form):
    import datetime
    now = datetime.datetime.today()
    beneficiario = db.benefs2[form.vars.id]
 
keybenef=db(db.keys2benefs.keybenef==beneficiario.key_Registro).select()
 
db(db.keys2benefs.id==keybenef[0].id).update(benefid=beneficiario.id)
    coordinador = db.coordinadores[keybenef[0].coordid]
    fechas =
db((db.fechas.fechaTramite>now)&(db.fechas.regional==coordinador.regional)&(db.fechas.full<db.fechas.cargaMax)).select(db.fechas.ALL,orderby=db.fechas.fechaTramite)
 
db(db.benefs2.id==beneficiario.id).update(coordid=keybenef[0].coordid)
    db(db.benefs2.id==beneficiario.id).update(fechasid=fechas[0].id)
    db(db.fechas.id==fechas[0].id).update(full=fechas[0].full+1)

#Beneficiarios
@auth.requires_login()
def update_benef2(form):
    now = request.now
    benef = db.benefs2[form.vars.id]
    keybenef=db(db.keys2benefs.keybenef==benef.key_Registro).select()
[0]
    db(db.keys2benefs.id==keybenef.id).update(benefs2_id=benef.id)
    coord = db.coordinadores[keybenef.coordinador_id]
    dates2 =
db((db.dates2.start>now)&(db.dates2.regional_id==coord.regional_id)&(db.dates2.xdia>db.dates2.cargados)).
\
        select(db.dates2.ALL,orderby=db.dates2.start)[0]
    benefs =
db(db.benefs2.dates2_id==dates2.id).select(db.benefs2.id,db.benefs2.tramite,db.benefs2.entrega,db.benefs2.tramite.count(),
\
        orderby=db.benefs2.tramite,groupby=db.benefs2.tramite)
    if len(benefs)>0:
        if
benefs[len(benefs)-1]._extra[db.benefs2.tramite.count()]<dates2.xhora:
            tramite=benefs[len(benefs)-1].benefs2.tramite
            entrega=benefs[len(benefs)-1].benefs2.entrega
        else:
            from datetime import timedelta
            HOUR = timedelta(hours=1)
            tramite=benefs[len(benefs)-1].benefs2.tramite+HOUR
            entrega=benefs[len(benefs)-1].benefs2.entrega+HOUR
    else:
        tramite=dates2.start
        entrega=dates2.inicio
 
db(db.benefs2.id==benef.id).update(dates2_id=dates2.id,tramite=tramite,entrega=entrega,coordnador_id=keybenef.coordinador_id)
    db(db.dates2.id==dates2.id).update(cargados=dates2.cargados
+1,xcargar=dates2.xdia-(dates2.cargados+1))

@auth.requires_login()
def crea_benef():
    return dict(form=crud.create(db.benefs2, next=URL(r=request,
f='benefs2_regist'),onaccept=update_benef2))

And this when we try to show as a list

@auth.requires_login()
def benefs2_regist():
    if len(request.args): page=int(request.args[0])
    else: page=0
    items_per_page=25
    limitby=(page*items_per_page,(page+1)*items_per_page+1)
    benefs=db(db.benefs2.creadoPor==auth.user.id).\
 
select(db.benefs2.id,db.benefs2.names,db.benefs2.apelPater,db.benefs2.apelMater,
\
        db.benefs2.tramite,orderby=~db.benefs2.id,limitby=limitby)
    nobenefs=db(db.benefs2.creadoPor==auth.user.id).count()
    return
dict(beneficiarios=benefs,page=page,items_per_page=items_per_page,nobenefs=nobenefs)

This are the views involved when we created one register

{{extend 'layout.html'}}
<h3>Registre los datos del Beneficiario y el Trabajador
correspondiente</h3>
{{=form}}

{{extend 'layout.html'}}
<h3>Usted registro a {{=nobenefs}} Beneficiarios, organizados en
bloques de {{=items_per_page}}</h3>
<h3>De clic sobre el nombre del beneficiario para ver el lugar, los
requisitos, etc. y ver el folio completo para imprimir</h3>
<ul>{{for i,benef in enumerate(beneficiarios):}}
    {{if i==items_per_page: break}}
        {{=LI(A('Folio ',benef.id,' ',benef.names,'
',benef.apelPater,' ',benef.apelMater,' fecha de
tramite:',benef.tramite, _href=URL(r=request, f='show_benef',
args=benef.id)))}}
    {{pass}}</ul>
{{if page:}}
<a href="{{=URL(r=request,args=[page-1])}}">anteriores</a>
{{pass}}
{{if len(beneficiarios)>items_per_page:}}
<a href="{{=URL(r=request,args=[page+1])}}">siguientes</a>
{{pass}}



On Jun 2, 9:01 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> why is counting records "select count(*) ...." crashing your mysql
> database? It seems to me the problem is not the web2py version.
>
> On Jun 2, 7:03 pm, drayco <antrod...@gmail.com> wrote:
>
> > Thank's a lot Dr. Massimo
>
> > do you use apache? Yes
> > mod_wsgi? Yes
> > do you use the built-in web server? No
> > do you see memory leaks? No
> > do you have web2py cron or on off? No
>
> > This is the firts error:
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 178, in restricted
> >     exec ccode in environment
> >   File "/home/drayco/webapps/seccion36/web2py/applications/init/
> > controllers/default.py", line 134, in <module>
> >   File "gluon/globals.py", line 96, in <lambda>
> >     self._caller = lambda f: f()
> >   File "gluon/tools.py", line 2036, in f
> >     return action(*a, **b)
> >   File "/home/drayco/webapps/seccion36/web2py/applications/init/
> > controllers/default.py", line 101, in crea_benef
> >     return dict(form=crud.create(db.benefs2, next=URL(r=request,
> > f='benefs2_regist'),onaccept=update_benef2))
> >   File "gluon/tools.py", line 2623, in create
> >     deletable=False,
> >   File "gluon/tools.py", line 2567, in update
> >     onvalidation=onvalidation, keepvalues=keepvalues):
> >   File "gluon/sqlhtml.py", line 870, in accepts
> >     onvalidation,
> >   File "gluon/html.py", line 1328, in accepts
> >     status = self._traverse(status)
> >   File "gluon/html.py", line 456, in _traverse
> >     newstatus = c._traverse(status) and newstatus
> >   File "gluon/html.py", line 456, in _traverse
> >     newstatus = c._traverse(status) and newstatus
> >   File "gluon/html.py", line 456, in _traverse
> >     newstatus = c._traverse(status) and newstatus
> >   File "gluon/html.py", line 456, in _traverse
> >     newstatus = c._traverse(status) and newstatus
> >   File "gluon/html.py", line 463, in _traverse
> >     newstatus = self._validate()
> >   File "gluon/html.py", line 1120, in _validate
> >     (value, errors) = validator(value)
> >   File "gluon/validators.py", line 413, in __call__
> >     if self.dbset(field == value).count():
> >   File "gluon/sql.py", line 3224, in count
> >     return self.select('count(*)')[0]._extra['count(*)']
> >   File "gluon/sql.py", line 3096, in select
> >     rows = response(query)
> >   File "gluon/sql.py", line 3091, in response
> >     db._execute(query)
> >   File "gluon/sql.py", line 932, in <lambda>
> >     self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> >   File "build/bdist.linux-i686/egg/MySQLdb/cursors.py", line 166, in
> > execute
> >     self.errorhandler(self, exc, value)
> >   File "build/bdist.linux-i686/egg/MySQLdb/connections.py", line 35,
> > in defaulterrorhandler
> >     raise errorclass, errorvalue
> > OperationalError: (1053, 'Server shutdown in progress')
>
> > And 1 second after:
>
> > Traceback (most recent call last):
> >   File "gluon/main.py", line 435, in wsgibase
> >     BaseAdapter.close_all_instances(BaseAdapter.rollback)
> >   File "gluon/sql.py", line 754, in close_all_instances
> >     action(instance)
> >   File "gluon/sql.py", line 1350, in rollback
> >     self._connection.rollback()
> > OperationalError: (2006, 'MySQL server has gone away')
>
> > On Jun 2, 6:47 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > Try
>
> > >http://web2py.com/examples/static/1.77.3/web2py_src.zip
>
> > > some version are there and some not. Those obviously buggy have been
> > > deleted.
>
> > > Anyway, I'd like to understand the problem.
> > > do you use apache? mod_wsgi?
> > > do you use the built-in web server?
> > > do you see memory leaks?
> > > do you have web2py cron or on off?
>
> > > Massimo
>
> > > On Jun 2, 6:06 pm, drayco <antrod...@gmail.com> wrote:
>
> > > > Where can I download web2py 1.77.3?
>
> > > > Because my application that's run in webfaction, with MySQL and web2py
> > > > 1.78.3 needs to restart 4 times at day?
>
> > > > And MySql rollback today, and I obtained a error that's say "server in
> > > > process to shutdown"
>
> > > > With web2py 1.77.3 and 1.66.5 I didn't need to do that action.
>
>

Reply via email to