Hello Massimo!
I send you the complete traceback (see the attach file).
Thanks a lot for web2py and your kindness for taking the time to look at
that strange problem!
--
web2py™ administrative interface
Site
Edit
About
Errors
Versioning
Logout
Debug
Help
Error ticket for "mm"
Ticket ID
127.0.0.1.2012-11-14.19-52-34.bbc92967-4c0f-4038-8129-5e4e912b404f
<type 'exceptions.TypeError'> format requires a mapping
Version
web2py™ (2, 2, 1, datetime.datetime(2012, 10, 21, 16, 57, 4), 'stable')
Python Python 2.7.3: /usr/bin/python
Traceback
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.
Traceback (most recent call last):
File "/home/julien/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/home/julien/web2py/applications/mm/controllers/default.py", line 291,
in <module>
File "/home/julien/web2py/gluon/globals.py", line 188, in <lambda>
self._caller = lambda f: f()
File "/home/julien/web2py/applications/mm/controllers/default.py", line 210,
in user
return dict(form=auth())
File "/home/julien/web2py/gluon/tools.py", line 1235, in __call__
return getattr(self, args[0])()
File "/home/julien/web2py/gluon/tools.py", line 2095, in login
self.log_event(log, user)
File "/home/julien/web2py/gluon/tools.py", line 1692, in log_event
origin=origin, user_id=user_id)
File "/home/julien/web2py/gluon/dal.py", line 7806, in insert
ret = self._db._adapter.insert(self,self._listify(fields))
File "/home/julien/web2py/gluon/dal.py", line 1155, in insert
query = self._insert(table,fields)
File "/home/julien/web2py/gluon/dal.py", line 1151, in _insert
values = ','.join(self.expand(v,f.type) for f,v in fields)
File "/home/julien/web2py/gluon/dal.py", line 1151, in <genexpr>
values = ','.join(self.expand(v,f.type) for f,v in fields)
File "/home/julien/web2py/gluon/dal.py", line 1306, in expand
return str(self.represent(expression,field_type))
File "/home/julien/web2py/gluon/dal.py", line 1720, in represent
if obj == '' and not fieldtype[:2] in ['st', 'te', 'pa', 'up']:
File "/home/julien/web2py/gluon/languages.py", line 363, in __eq__
return str(self) == str(other)
File "/home/julien/web2py/gluon/languages.py", line 360, in __str__
self.T.translate(self.m, self.s))
File "/home/julien/web2py/gluon/languages.py", line 878, in translate
message = self.params_substitution(message, symbols)
File "/home/julien/web2py/gluon/languages.py", line 855, in
params_substitution
message = message % symbols
TypeError: format requires a mapping
Error snapshot help
<type 'exceptions.TypeError'>(format requires a mapping)
inspect attributes
Frames
File /home/julien/web2py/gluon/restricted.py in restricted at line 212 code
arguments variables
File /home/julien/web2py/applications/mm/controllers/default.py in <module>
at line 291 code arguments variables
File /home/julien/web2py/gluon/globals.py in <lambda> at line 188 code
arguments variables
File /home/julien/web2py/applications/mm/controllers/default.py in user at
line 210 code arguments variables
File /home/julien/web2py/gluon/tools.py in __call__ at line 1235 code
arguments variables
File /home/julien/web2py/gluon/tools.py in login at line 2095 code
arguments variables
File /home/julien/web2py/gluon/tools.py in log_event at line 1692 code
arguments variables
File /home/julien/web2py/gluon/dal.py in insert at line 7806 code arguments
variables
File /home/julien/web2py/gluon/dal.py in insert at line 1155 code arguments
variables
File /home/julien/web2py/gluon/dal.py in _insert at line 1151 code
arguments variables
File /home/julien/web2py/gluon/dal.py in <genexpr> at line 1151 code
arguments variables
File /home/julien/web2py/gluon/dal.py in expand at line 1306 code arguments
variables
File /home/julien/web2py/gluon/dal.py in represent at line 1720 code
arguments variables
File /home/julien/web2py/gluon/languages.py in __eq__ at line 363 code
arguments variables
File /home/julien/web2py/gluon/languages.py in __str__ at line 360 code
arguments variables
File /home/julien/web2py/gluon/languages.py in translate at line 878 code
arguments variables
File /home/julien/web2py/gluon/languages.py in params_substitution at line
855 code arguments variables
Function argument list
(self=<gluon.languages.translator object>, message='User %(id)s Logged-in',
symbols=("<Row \x1e'username': 'julien', 'first_name': 'Julie...f9da1adefd98',
'registration_key': '', 'id': 12\x1f>",))
Code listing
850.
851.
852.
853.
854.
855.
856.
857.
858.
859.
if part == s:
part = regex_plural_dict.sub(sub_dict, s)
if part == s:
return m.group(0)
return part
message = message % symbols
message = regex_plural.sub(sub_plural, message)
return message
def translate(self, message, symbols):
Variables
symbols ("<Row \x1e'username': 'julien', 'first_name':
'Julie...f9da1adefd98', 'registration_key': '', 'id': 12\x1f>",)
message 'User %(id)s Logged-in'
Context
locals request session response
In file: /home/julien/web2py/applications/mm/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.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.
211.
212.
213.
214.
215.
216.
217.
218.
219.
220.
221.
222.
223.
224.
225.
226.
227.
228.
229.
230.
231.
232.
233.
234.
235.
236.
237.
238.
239.
240.
241.
242.
243.
244.
245.
246.
247.
248.
249.
250.
251.
252.
253.
254.
255.
256.
257.
258.
259.
260.
261.
262.
263.
264.
265.
266.
267.
268.
269.
270.
271.
272.
273.
274.
275.
276.
277.
278.
279.
280.
281.
282.
283.
284.
285.
286.
287.
288.
289.
290.
291.
292.
# -*- coding: utf-8 -*-
def _set_lang():
#lang = request.vars._lang or session._lang or 'en'
T.current_languages = ['en', 'en-en', 'en-us']
if request.vars._lang:
session._lang = request.vars._lang
if session._lang:
lang = session._lang
elif T.accepted_language is not None:
lang = T.accepted_language[:2]
else:
lang = 'en'
T.force(lang)
return lang
def __flatpage():
lang = _set_lang()
title = subtitle = body = ''
flatpage_id = None
form = ''
view = DEFAULT_FLATPAGE_VIEW
"""
if request.vars and auth.user and auth.user.email == FLATPAGES_ADMIN:
record = db.flatpage(request.get_vars.id)
form = SQLFORM(db.flatpage, record)
if form.accepts(request, session):
response.flash = T('Page saved')
elif form.errors:
response.flash = T('Errors!')
else:
response.flash = T('Edit Page')
"""
if not form:
# search flatpage according to the current request
query = db.flatpage.c==request.controller
query &= db.flatpage.f==request.function
if request.args:
query &= db.flatpage.args==request.args(0)
else:
query &= (db.flatpage.args==None)|(db.flatpage.args=='')
query &= db.flatpage.lang==lang
# execute the query, fetch one record (if any)
flatpage = db(query).select(orderby=~db.flatpage.created_on,
limitby=(0, 1)).first()
if flatpage:
flatpage_id = flatpage.id
title = flatpage.title
subtitle = flatpage.subtitle
body = flatpage.body
view = flatpage.view
else:
response.flash = T('Page Not Found!')
"""
if auth.user and auth.user.email == FLATPAGES_ADMIN:
# if user is authenticated, show edit button:
form = A(T('edit'), _href=URL(vars=dict(id=flatpage_id)))
"""
response.title = title
response.subtitle = subtitle
response.view = view
body = XML(body)
return dict(text_footer=TEXT_FOOTER, body=body, form=form)
def _add_visit():
try:
db(db.visitors.year == CURRENT_YEAR).update(visits = db.visitors.visits
+ 1)
except:
db.visitors.insert(year = CURRENT_YEAR, visits = 1)
def index():
lang = _set_lang()
news = db(db.news.is_active == True).select(db.news.ALL,
orderby=~db.news.id)
nws = []
for nw in news:
if lang == 'en':
nws.append((nw.title_en, nw.content_en))
else:
nws.append((nw.title_fr, nw.content_fr))
response.view = 'index.html'
return dict(news=nws, lang=lang)
def contact_us():
_set_lang()
def queue_mail(form):
db_email.queue.insert(email=EMAIL_SMM,
replyto=form.vars.email,
subject=form.vars.subject,
message=form.vars.message)
crud.messages.submit_button = T('Send')
form = crud.create(table=db_email.user_message,
next=URL(),
onaccept=queue_mail,
message=T('Your message have been send'))
response.view = 'contact_us.html'
return dict(form=form)
def other_websites():
_set_lang()
sites = db().select(db.website.ALL, orderby=db.website.description)
response.view = 'other_websites.html'
return dict(sites=sites)
def photos():
lang = _set_lang()
response.view = 'photos.html'
return dict(lang=lang)
def mailing_list():
response.view = 'mailing_list.html'
return dict()
@auth.requires_membership('admin')
def sysadmin():
response.view = 'sysadmin2.html'
return dict()
def mother_meera():
return __flatpage()
def darshan():
return __flatpage()
def mm_society():
return __flatpage()
def books():
return __flatpage()
def quebec():
return __flatpage()
def ontario():
return __flatpage()
def alberta():
return __flatpage()
def bc():
return __flatpage()
def donate():
return __flatpage()
def donate_with_paypal():
return dict()
def contact():
return __flatpage()
def visit_mother():
return __flatpage()
def organizing_darshan():
return __flatpage()
def school_in_india():
return __flatpage()
def meditation_group():
return __flatpage()
def children_weekend():
return __flatpage()
def about():
return __flatpage()
def error():
return dict()
def user():
return dict(form=auth())
def download():
return response.download(request,db)
def call():
return service()
#####################################################################################
def mail_subscribe():
"""
username = request.post_vars.username
email = request.post_vars.email
# si email pas déjà dans la bd alors ajouter dans la bd
"""
crud.messages.submit_button = T('Subscribe')
form = crud.create( db.mail_list,
next=URL('index'),
message=T('You have been registered')
)
"""
username = request.post_vars.username
email = request.post_vars.email
row = db(db.mail_list==email).select().first()
if row == None:
db.mail_list.insert(username=username, email=email)
msg = T('email added')
else:
msg = T('email already there')
"""
return dict(form=form)
def mail_unsubscribe():
"""
_id = request.get_vars.id
username = request.get_vars.username
email = request.get_vars.email
#décoder les attributs et modifier le champ is_active (=False)
_id = request.get_vars.id
db(db.mail_list.id==_id).update(is_active=False)
#retourne un message d'info
"""
return dict(username=username, email=email)
@auth.requires_membership('admin')
def send_mail():
# encoder(id, username, email)
# ajouter le lien suivant à la fin du message html:
# 'a href="---/default/mail_unsubscribe/id=id&username=username&email">to
unsubscribe</a>
mails = db().select(db.mail_list.ALL)
msg = db(db.message.mailed==False).select().first()
for m in mails:
mail.send( to=[m.email],
cc='[email protected]',
subject=msg.subject,
message=[msg.body_text, XML(msg.body_html)]
)
db(db.message.id==msg.id).update(mailed=True)
return dict(message=msg, mails=mails)
@auth.requires_membership('admin')
def test_mail():
mail.send( to=['[email protected]'],
subject='test',
message=['test', '<html> test </html>']
)
return dict()
response._vars=response._caller(user)
Powered by web2py™ created by Massimo Di Pierro ©2007-2012 - Admin language