could you please tell me how to do/find a print statement?
or direct me to a chapter in the documentation or something?


On Mar 16, 4:07 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> can you add some print statements to determine which lines are
> executed and which not? I suspect a logic problem.
>
> On Mar 16, 3:39 am, mohammed al-moustady <mohd.moust...@gmail.com>
> wrote:
>
>
>
> > here is my db.py
>
> > db.define_table('time_table',
> >     Field('time_in','time'),
> >     Field('time_out','time')
> > )
>
> > db.define_table('years',
> >     Field('year_number','string')
> > )
>
> > db.define_table('buildings',
> >     Field('b_number','string')
> > )
>
> > db.define_table('levels',
> >     Field('l_number','string')
> > )
>
> > db.define_table('room',
> >     Field('building_number',db.buildings),
> >     Field('level','string'),
> >     Field('room_number','string'),
> >     Field('area','string')
> > )
>
> > db.define_table('module',
> >     Field('name','string'),
> >     Field('module_number','string'),
> >     Field('year',db.years)
> > )
>
> > db.define_table('reservation',
> >     Field('room',db.room),
> >     Field('module',db.module),
> >     Field('Time_IN',db.time_table),
> >     Field('Time_OUT',db.time_table),
> >     Field('Date','date')
> >     )
>
> > db.module.year.requires=IS_IN_DB(db,'years.id','years.year_number')
> > db.room.building_number.requires=IS_IN_DB(db,'buildings.id','buildings.b_nu 
> > mber')
> > db.room.level.requires=IS_IN_DB(db,'levels.id','levels.l_number')
> > db.reservation.room.requires=IS_IN_DB(db,'room.id','room.room_number')
> > db.reservation.module.requires=IS_IN_DB(db,'module.id','module.name')
> > db.reservation.Time_IN.requires=IS_IN_DB(db,'time_table.id','time_table.tim 
> > e_in')
> > db.reservation.Time_OUT.requires=IS_IN_DB(db,'time_table.id','time_table.ti 
> > me_out')
>
> > and here is my default.py in controler:
> > def index():
>
> >     return dict(message="")
>
> > def room_reg():
> >     form=SQLFORM(db.room)
> >     if form.accepts(request.vars,session):
> >         response.flash='new record inserted'
> >     records=SQLTABLE(db().select(db.room.ALL))
>
> >     return dict(form=form,records=records)
>
> > def module_reg():
> >     form=SQLFORM(db.module)
> >     if form.accepts(request.vars,session):
> >         response.flash='new record inserted'
> >     records=SQLTABLE(db().select(db.module.ALL))
>
> >     return dict(form=form,records=records)
>
> > def validation(form):
>
> >     st1=form.vars.Time_IN
> >     en1=form.vars.Time_OUT
> >     dbselect=db(db.reservation.Date==form.vars.Date).select()
>
> >     if en1<st1 :
> >         form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
>
> >     for i in dbselect:
> >         st2=i.Time_IN
> >         en2=i.Time_OUT
> >         if st1==st2 or en1==en2:
> >             form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         elif st2>st1 and en2>en1:
> >             if st2>en1:
> >                 pass
> >             else:
> >                 form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         elif st2<st1 and en2<en1:
> >             if en2<st1:
> >                 pass
> >             else:
> >                 form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         elif st2>st1 and en2<en1:
> >             form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         else:
> >             pass
>
> > def reservation():
> >     form=SQLFORM(db.reservation)
> >     if form.accepts(request.vars,session, onvalidation=validation):
> >         response.flash='new record inserted'
> >     records=SQLTABLE(db().select(db.reservation.ALL))
> >     dt=db(db.reservation.Date==form.vars.Date).select()
> >     return dict(form=form,records=records,dt=dt)
>
> > My issue is in the Validation function for the form processing in the
> > function reservation()
> > first I am validating if the user has input a time in later than time
> > out:
>
> >     st1=form.vars.Time_IN
> >     en1=form.vars.Time_OUT
>
> >     if en1<st1 :
> >         form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
>
> > and it works fine.
>
> > then I tried to do extra validation at which I select from the
> > database the same date inputed by the user:
>
> > dbselect=db(db.reservation.Date==form.vars.Date).select()
>
> > then do some logic to see if there is a conflicting time already in
> > the database in that same particular date:
>
> >  for i in dbselect:
> >         st2=i.Time_IN
> >         en2=i.Time_OUT
> >         if st1==st2 or en1==en2:
> >             form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         elif st2>st1 and en2>en1:
> >             if st2>en1:
> >                 pass
> >             else:
> >                 form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         elif st2<st1 and en2<en1:
> >             if en2<st1:
> >                 pass
> >             else:
> >                 form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         elif st2>st1 and en2<en1:
> >             form.errors.Time_OUT='ÇáÑÌÇÁ ÊÚÏíá ÇáæÞÊ'
> >         else:
> >             pass
>
> > the problem is that the validation is completely ignored.
>
> > can any one help?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to