Modify

Opened 18 years ago

Closed 18 years ago

#1192 closed defect (fixed)

programming error when creating new forum

Reported by: anonymous Owned by: Radek Bartoň
Priority: normal Component: DiscussionPlugin
Severity: normal Keywords: programming error forum create
Cc: Trac Release: 0.10

Description (last modified by Noah Kantrowitz)

I've installed DiscussionPlugin and WebAdminPlugin, when attempting to create new forum from Discussion page, I get this error:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/tracdiscussion/core.py", line 72, in process_request
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 32, in render_discussion
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 404, in _do_action
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 932, in add_forum
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: can't adapt

When attempting to create it from webadmin, I get this:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/web_ui.py", line 109, in process_request
    path_info)
  File "build/bdist.linux-i686/egg/tracdiscussion/admin.py", line 42, in process_admin_request
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 19, in render_discussion
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 75, in _get_items
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 709, in get_group
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: invalid input syntax for integer: ""

I always fill-in all form fields and I'm logged in as admin with all priviledges (including those four DISCUSSION_*)

Attachments (0)

Change History (18)

comment:1 Changed 18 years ago by anonymous

Sorry, for the mess. I'll use Preview next time. So again

From Web admin, I get this:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/web_ui.py", line 109, in process_request
    path_info)
  File "build/bdist.linux-i686/egg/tracdiscussion/admin.py", line 42, in process_admin_request
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 19, in render_discussion
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 75, in _get_items
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 709, in get_group
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: invalid input syntax for integer: ""


From /discussion - Add new forum, I get this:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/tracdiscussion/core.py", line 72, in process_request
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 32, in render_discussion
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 404, in _do_action
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 932, in add_forum
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: can't adapt

Thanks.

Ales Zoulek

comment:2 Changed 18 years ago by Noah Kantrowitz

Description: modified (diff)

Fixing formatting

comment:3 Changed 18 years ago by Radek Bartoň

I tried to evoke this error but without success. It has to do something with missing value for hidden field "group" specifying under which group should forum be created. Try to describe situation where you get this error more preciselly especially if you have created any forum groups before and what server and what Trac version exactly do you run your Trac at, please.

comment:4 Changed 18 years ago by anonymous

Ah. So I need to create group first? But I doesnt work either.

The form looks like this (from firefox webdeveloper toolbar):

This is form for creating group:

Form:
Id	new-group-form
Name	
Method	post
Action	/test/admin/discussion/group

Elements

Index Id Name Type Value Label Size Maximum Length State
0 FORM_TOKEN text e7e1cbf01546cefd5f3c18ab
1 fieldset
2 name text my test name
3 description text my test description
4 submit submit Add
5 discussion_action text post-add

Group creating dies on:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/web_ui.py", line 109, in process_request
    path_info)
  File "build/bdist.linux-i686/egg/tracdiscussion/admin.py", line 42, in process_admin_request
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 32, in render_discussion
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 314, in _do_action
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 921, in add_group
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: can't adapt

And the form for creating forum looks like:

Form

Id Name Method Action
new-forum-form post /test/admin/discussion/forum

Elements

Index Id Name Type Value Label Size Maximum Length State
0 FORM_TOKEN hidden e7e1cbf01546cefd5f3c18ab
1 fieldset
2 name name text test name Name:
3 subject subject text test subj Subject:
4 description description text long desc.... Description:
5 moderators moderators select Moderators:
6 group hidden
7 submit submit Add
8 discussion_action hidden post-add

And this dies on:

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/web_ui.py", line 109, in process_request
    path_info)
  File "build/bdist.linux-i686/egg/tracdiscussion/admin.py", line 42, in process_admin_request
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 19, in render_discussion
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 75, in _get_items
  File "build/bdist.linux-i686/egg/tracdiscussion/api.py", line 709, in get_group
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
  File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
    return self.cursor.execute(sql_escape_percent(sql), args)
ProgrammingError: invalid input syntax for integer: ""

I'm using trac 0.10.3 (from gentoo ebuild), and latest discussion plugin (0.10 i think). I'm trying to figure out, where could be the problem or what to send you more to help you... :( Other plugins, I've tested so far are working, so I guest, that my instalation is not cripled in some way..

comment:5 in reply to:  4 Changed 18 years ago by Radek Bartoň

Status: newassigned

Replying to anonymous:

Ah. So I need to create group first? But I doesnt work either.

No, you needn't. I just asked if you did so because it could matter. Thanks for your info about form values. There is obviously group value not filled. I could check if value is not empty while processing form and fix it for this case, but I'm pretty curious how is it possible that this situation occurs. Could you please post where you are running your Trac at (I mean web server, i. e apache+mod_python, apache+cgi, FastCG, tracd, ...)? If you attach relevant parts of log in DEBUG mode it could be helpfull too but I'm not sure about that.

comment:6 Changed 18 years ago by Radek Bartoň

And you could post html representation of that form too and info about version of your ClearSilver because this could be only some chnanges in templates rendening behaviour. Thanks.

comment:7 Changed 18 years ago by anonymous

Now i'm using tracd, but it didnt work on apache cgi either.

I've uncommented /usr/lib/python2.4/site-packages/trac/db/util.py line 47 and 49, so I could see SQL queries when creating group. Here it goes, but I seems to me that it's OK. :(

execute 'SELECT username,action FROM permission'
execute 'SELECT username,action FROM permission'
execute 'SELECT last_visit FROM session WHERE sid=%s AND authenticated=%s'
('c19572550b23f19517d99852', 0)
execute 'SELECT last_visit FROM session WHERE sid=%s AND authenticated=%s'
('c19572550b23f19517d99852', 0)
execute "SELECT value FROM system WHERE name='repository_dir'"
execute "SELECT value FROM system WHERE name='repository_dir'"
execute 'SELECT rev FROM revision ORDER BY -LENGTH(rev), rev DESC LIMIT 1'
execute 'SELECT rev FROM revision ORDER BY -LENGTH(rev), rev DESC LIMIT 1'
execute 'INSERT INTO forum_group (name, description) VALUES (%s, %s)'
(u'gru', u'desccccc')
execute 'INSERT INTO forum_group (name, description) VALUES (%s, %s)'
(u'gru', u'desccccc')
127.0.0.1 - - [09/Feb/2007 00:37:36] "POST /test/admin/discussion/group HTTP/1.1" 500 -

clearsilver version 0.10.1

comment:8 Changed 18 years ago by ales.zoulek@…

HTML representation of the forms could be found at http://tmp.al3x.cz/forum.html http://tmp.al3x.cz/group.html

comment:9 Changed 18 years ago by Radek Bartoň

OK. I've post some changes to changeset 1941. Error you have in admin is still mystery for me since is is somehow system specific but it shoud be fixed now, at least in that case. Second error in discussion was caused by using str() function to convert to string instead of unicode() which is needed in Trac 0.10. Please test it and let me know if I could close this ticket. Many thanks.

comment:10 Changed 18 years ago by ales.zoulek@…

Chmm.. Now I'm getting 'cant adapt' exeptions every times, it tries to save s/t to the database.

I can send you the egg file, but I doubt it would help. I can try to dive into trac plugins system more deeper and try find the problem myself. I have the strange feeling it's somethink stupid I did somewhere in my system.

comment:11 Changed 18 years ago by Radek Bartoň

Damn, I think that plugin will have some part in this error too since other plugins works correctly. So if you want you could open trac.ini and edit these lines:

[logging]
log_file = trac.log
log_level = DEBUG
log_type = file

Then restart server, evoke error and post me trac.log file or its part which will be in log dir in your Trac environment. This will tell me more than only traceback (maybe :-) ).

comment:12 Changed 18 years ago by anonymous

There is a log file.

 1 2007-02-09 02:40:45,897 Trac[cache] INFO: Syncing with repository (None to 0)                                                                                          
 2 2007-02-09 02:40:45,920 Trac[api] DEBUG: message: None
 3 2007-02-09 02:40:45,921 Trac[api] DEBUG: topic: None
 4 2007-02-09 02:40:45,921 Trac[api] DEBUG: forum: None
 5 2007-02-09 02:40:45,921 Trac[api] DEBUG: group: None
 6 2007-02-09 02:40:45,921 Trac[api] DEBUG: component: admin
 7 2007-02-09 02:40:45,921 Trac[api] DEBUG: action: post-add
 8 2007-02-09 02:40:45,922 Trac[api] DEBUG: modes: ['group-post-add', 'admin-group-list']
 9 2007-02-09 02:40:45,922 Trac[api] DEBUG: doing group-post-add mode action
10 2007-02-09 02:40:45,922 Trac[api] DEBUG: INSERT INTO forum_group (name, description) VALUES (forname, for desc)
11 2007-02-09 02:40:45,923 Trac[main] ERROR: can't adapt
12 Traceback (most recent call last):
13   File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 387, in dispatch_request
14     dispatcher.dispatch(req)
15   File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 237, in dispatch
16     resp = chosen_handler.process_request(req)
17   File "/usr/lib/python2.4/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.4.egg/webadmin/web_ui.py", line 109, in process_request
18     path_info)
19   File "/root/discussionplugin/0.10/tracdiscussion/admin.py", line 42, in process_admin_request
20     content = api.render_discussion(req, cursor)
21   File "/root/discussionplugin/0.10/tracdiscussion/api.py", line 32, in render_discussion
22     is_moderator)
23   File "/root/discussionplugin/0.10/tracdiscussion/api.py", line 314, in _do_action
24     self.add_group(cursor, new_name, new_description)
25   File "/root/discussionplugin/0.10/tracdiscussion/api.py", line 921, in add_group
26     cursor.execute(sql, (name, description))
27   File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
28     return self.cursor.execute(sql_escape_percent(sql), args)
29   File "/usr/lib/python2.4/site-packages/trac/db/util.py", line 50, in execute
30     return self.cursor.execute(sql_escape_percent(sql), args)
31 ProgrammingError: can't adapt

comment:13 Changed 18 years ago by anonymous

Just being curious, why there aren't any qoutes around the values in the insert query?

comment:14 Changed 18 years ago by Radek Bartoň

That's OK. This is only printed this way. Looks like there is no reason for that error. I don't even know what does it mean since google is not friendly for this time :-)

comment:15 Changed 18 years ago by anonymous

Hey! :) This works for me... So I guess, there is some error in the cursor / database configuration, so that it doesn't handle substitutions correctly?

918     def add_group(self, cursor, name, description):
919         sql = "INSERT INTO forum_group (name, description) VALUES (\'%s\', \'%s\')"                                                                                   
920         self.log.debug(sql % (name, description))
921         cursor.execute(sql % (name, description))

comment:16 Changed 18 years ago by Radek Bartoň

I found this http://trac.edgewall.org/ticket/3501 . Maybe this is your case...

comment:17 Changed 18 years ago by anonymous

I see... Seems like gentoo?-postgres--specific bug in psycopg implementation. The cursor.execute() method should be realy able to make correct substitution with value escaping by it self. But, somehow, it does not. Geee...

Thanks for your efford anyway. I think, you can close this ticket as it's not your fault. :)

comment:18 Changed 18 years ago by Radek Bartoň

Resolution: fixed
Status: assignedclosed

OK, closing this ticket. It has to do something with unicode so check your system, PostreSQL and other libraries for Unicode support.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Radek Bartoň.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.