I still getting a error, but now is different :S
Error traceback
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
Traceback (most recent call last):
File "/home/rui/Public/web2py/gluon/restricted.py", line 107, in restricted
exec ccode in environment
File
"/home/rui/Public/web2py/applications/Dominos_Times/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/Dominos_Times/controllers/default.py>,
line 121, in <module>
File "/home/rui/Public/web2py/gluon/globals.py", line 97, in <lambda>
self._caller = lambda f: f()
File
"/home/rui/Public/web2py/applications/Dominos_Times/controllers/default.py"
<http://127.0.0.1:8000/admin/default/edit/Dominos_Times/controllers/default.py>,
line 16, in user
return dict(form=auth())
File "/home/rui/Public/web2py/gluon/tools.py", line 436, in __call__
return self.login()
File "/home/rui/Public/web2py/gluon/tools.py", line 724, in login
next = self.url(next.replace('[id]', str(form.vars.id)))
AttributeError: 'list' object has no attribute 'replace'
In file:
/home/rui/Public/web2py/applications/Dominos_Times/controllers/default.py
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
# # sample index page with internationalization (T)
response <http://127.0.0.1:8000/examples/global/vars/response>.menu
=[['Login', False, URL
<http://127.0.0.1:8000/examples/global/vars/URL>(r=request
<http://127.0.0.1:8000/examples/global/vars/request>,
f='user/login')],
['Logout', False, URL
<http://127.0.0.1:8000/examples/global/vars/URL>(r=request
<http://127.0.0.1:8000/examples/global/vars/request>,
f='user/logout')]]
def index():
link_create=URL
<http://127.0.0.1:8000/examples/global/vars/URL>(r=request
<http://127.0.0.1:8000/examples/global/vars/request>,
f='customcreate')
link_search=URL
<http://127.0.0.1:8000/examples/global/vars/URL>(r=request
<http://127.0.0.1:8000/examples/global/vars/request>, f='list_all')
return dict(link_create=link_create, link_search=link_search)
# # uncomment the following if you have defined "auth" and "crud" in models
def user():
return dict(form=auth())
@auth.requires_login()
def list_all():
form=FORM <http://127.0.0.1:8000/examples/global/vars/FORM>(TABLE
<http://127.0.0.1:8000/examples/global/vars/TABLE>(TR
<http://127.0.0.1:8000/examples/global/vars/TR>('Select Store:',
SELECT
<http://127.0.0.1:8000/examples/global/vars/SELECT>('All',1,2,3,4,5,6,7,8,9,10,11,12,13,14,
value='All', _name='store_id', requires=IS_NOT_EMPTY
<http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY>())),
TR
<http://127.0.0.1:8000/examples/global/vars/TR>('Reason:', SELECT
<http://127.0.0.1:8000/examples/global/vars/SELECT>('All',
'Afpöntun',
'Annað',
'Ekki heimild',
'Ómóttekin',
'Ósótt',
'Remake',
'Röng búð',
'Sein',
'Símamistök',
'Staffamatur',
value='All', _name='reason',
requires=IS_NOT_EMPTY
<http://127.0.0.1:8000/examples/global/vars/IS_NOT_EMPTY>())),
TR
<http://127.0.0.1:8000/examples/global/vars/TR>('Date', INPUT
<http://127.0.0.1:8000/examples/global/vars/INPUT>(_class="date",
_id="date_field", _type="date",_name="date", _value="All")),
("",INPUT
<http://127.0.0.1:8000/examples/global/vars/INPUT>(_type="submit",_value="Go"))))
query=""
db_store=db.databasedp.Store_id
db_reason=db.databasedp.reason
db_date=db.databasedp.date
st_store=request
<http://127.0.0.1:8000/examples/global/vars/request>.vars.store_id
st_reason=request
<http://127.0.0.1:8000/examples/global/vars/request>.vars.reason
st_date=request
<http://127.0.0.1:8000/examples/global/vars/request>.vars.date
if st_date!="All":
q_date=db_date==st_date
else:
q_date=db_date==db_date
if st_store!="All":
q_store=db_store==st_store
else:
q_store=db_store==db_store
if st_reason!="All":
q_reason=db_reason==st_reason
else:
q_reason=db_reason==db_reason
if st_store=="All" and st_reason=="All" and st_date=="All": #Se
todos forem all
query=db().select(db.databasedp.ALL)
else:
query=db(q_store&q_date&q_reason).select()
return dict(form=form, query=query)
@auth.requires_login()
def customread():
id_order=request
<http://127.0.0.1:8000/examples/global/vars/request>.args[0]
return dict(crudread=crud.read(db.databasedp, int(id_order)))
@auth.requires_login()
def customupdate():
id_order=request
<http://127.0.0.1:8000/examples/global/vars/request>.args[0]
#if db.databasedp.id(id_order):
crud_output=crud.update(db.databasedp, int(id_order) ,next=URL
<http://127.0.0.1:8000/examples/global/vars/URL>(r=request
<http://127.0.0.1:8000/examples/global/vars/request>,args=request
<http://127.0.0.1:8000/examples/global/vars/request>.args[0]))
return dict(crudupdate=crud_output)
#[email protected]_login()
#def customcreate():
# try:
# if session.create:
# pass
# except:
# session.create=[]
# form = crud.create('databasedp',onvalidation=lambda form:r(form),
onaccept=lambda form: f(form))
# return dict(form=form)
#def f(form):
# if session.create:
# session.create.append(form.vars.id)
# else:
# session.create=[form.vars.id]
#def r(form):
# form.vars.total_payd=form.vars.total_amount-form.vars.total_credit
@auth.requires_login()
def customcreate():
crud.settings.keepvalues = True
if not session
<http://127.0.0.1:8000/examples/global/vars/session>.create: session
<http://127.0.0.1:8000/examples/global/vars/session>.create = []
form = crud.create(db.ttt, onvalidation=r, onaccept=f)
return dict(form=form)
def f(form): session
<http://127.0.0.1:8000/examples/global/vars/session>.create.append(form.vars.id)
def r(form): form.vars.total_payd=form.vars.total_amount-form.vars.total_credit
response <http://127.0.0.1:8000/examples/global/vars/response>._vars=response
<http://127.0.0.1:8000/examples/global/vars/response>._caller(user)
On Wed, Jun 10, 2009 at 3:13 AM, mdipierro <[email protected]> wrote:
>
> There is a bug in keepvalues and crud. I fixed it in trunk but that
> was not causing your problem.
>
> This code works for me:
>
> @auth.requires_login()
> def customcreate():
> crud.settings.keepvalues = True
> if not session.create: session.create = []
> form = crud.create(db.ttt, onvalidation=r, onaccept=f)
> return dict(form=form)
>
> def f(form): session.create.append(form.vars.id)
> def r(form): form.vars.total_payd=form.vars.total_amount-
> form.vars.total_credit
>
> Massimo
>
> On Jun 9, 9:35 pm, Rui Gomes <[email protected]> wrote:
> > yes i set crud.settings.keepvalues=True, and what happen is when i call
> the
> > function customcreate, the function don't return the form but a
> redirection
> > to the index page, but if i try the same application with 1.62 version
> and
> > work fine :(
> >
> > PS: i double check in different machines
> >
> > On Mon, Jun 8, 2009 at 3:26 PM, mdipierro <[email protected]>
> wrote:
> >
> > > I do not see how the last update may be causing this problem.
> > > have you set crud.settings.keepvalues somewhere?
> > > Is anybody else having problem with crud.create and the latest trunk?
> >
> > > Massimo
> >
> > > On Jun 8, 9:00 am, NewBeen <[email protected]> wrote:
> > > > This last update break my application,
> >
> > > > now my function
> >
> > > > ### Controller ####
> >
> > > > @auth.requires_login()
> > > > def customcreate():
> >
> > > > try:
> > > > if session.create:
> > > > pass
> > > > except:
> > > > session.create=[]
> >
> > > > try:
> > > > form = crud.create('databasedp',onvalidation=lambda form:r
> > > > (form), onaccept=lambda form: f(form)) #i just put this here to debug
> > > > except Exception, inst:
> > > > print inst
> >
> > > > return dict(form=form)
> >
> > > > def f(form):
> >
> > > > if session.create:
> > > > session.create.append(form.vars.id)
> > > > else:
> > > > session.create=[form.vars.id]
> >
> > > > def r(form):
> > > >
> form.vars.total_payd=form.vars.total_amount-form.vars.total_credit
> >
> > > > ################################################################
> >
> > > > Always return
> >
> > > > #####
> > > > (303, 'You are being redirected <a href="/Dominos_Times/default/
> > > > index">here</a>'
> > > > , {'Content-Type': 'text/html', 'Location': '/Dominos_Times/default/
> > > > index'})
> > > > ###
> >
> > > > But work fine in before this last update!
> >
> > > > On 8 Jun, 12:45, mdipierro <[email protected]> wrote:
> >
> > > > > in thunk in 5 minutes
> >
> > > > > crud.settings.keepvalues=True before calling crud.update()
> >
> > > > > On Jun 8, 5:14 am, NewBeen <[email protected]> wrote:
> >
> > > > > > Greetings,
> >
> > > > > > How can i do this put keepvalues=True when i use the function
> > > > > > crud.create()
> >
> > > > > > i already try:
> >
> > > > > > ### CODE ###
> >
> > > > > > form = crud.create('databasedp',onvalidation=lambda form:r(form))
> >
> > > > > > def r(form):
> > > > > > if form.accepts(request.vars,session,keepvalues=True):
> > > > > > response.flash="Accept form"
> >
> > > > > > ### END ###
> >
> > > > > > and
> >
> > > > > > ### CODE ###
> >
> > > > > > form = crud.create('databasedp', onaccept=lambda form: f(form))
> >
> > > > > > def f(form):
> > > > > > if form.accepts(request.vars,session,keepvalues=True):
> > > > > > response.flash="Accept form"
> >
> > > > > > #### END ####
> >
> > > > > > But nothing of this work :( any ideas?
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---