Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1109 (closed defect: fixed)

Opened 13 years ago

Last modified 10 years ago

[patch] Modeldesigner throws exception in save_state

Reported by: nyenyec Owned by: anonymous
Priority: high Milestone: 1.x
Component: Toolbox.ModelDesigner Version:
Severity: critical Keywords:


Trying to save the model in freshly quickstarted project I got an exception. (See below).

Here's what I did:

  • Installed TurboGears 1.0b1 on Windows
  • Created a project with identity titled "foobar"
  • Changed to the "foobar" directory, started "tg-admin toolbox"
  • Started the model designer
  • Created a class called "Foo"
  • Called "Save Current Session"
  • Looked at the log, saw the exception
2006-09-10 21:01:04,421 turbogears.controllers DEBUG Calling <function save_stat
e at 0x015F0AB0> with *((<turbogears.toolbox.designer.Designer object at 0x015EE
3D0>, u'{"name":"foobar", "models":{"Foo":{"name":"Foo", "parent_class":"SQLObje
ct", "table_name":"", "id_name":"", "columns":{}, "relations":{}}}, "ordered_mod
els":[]}')), **({'name': u'foo'})
10/Sep/2006:21:01:04 HTTP INFO Page handler: <function _wrapper at 0x0170C0F0>
Traceback (most recent call last):
  File "c:\python24\lib\site-packages\CherryPy-2.2.1-py2.4.egg\cherrypy\_cphttpt
ools.py", line 105, in _run
  File "c:\python24\lib\site-packages\CherryPy-2.2.1-py2.4.egg\cherrypy\_cphttpt
ools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\iden
tity\conditions.py", line 275, in _wrapper
    return fn( *args, **kw )
  File "<string>", line 3, in save_state
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\cont
rollers.py", line 326, in expose
    output = database.run_with_transaction(
  File "<string>", line 5, in run_with_transaction
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\data
base.py", line 246, in so_rwt
    retval = func(*args, **kw)
  File "<string>", line 5, in _expose
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\cont
rollers.py", line 343, in <lambda>
    mapping, fragment, args, kw)))
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\cont
rollers.py", line 367, in _execute_func
    output = errorhandling.try_call(func, *args, **kw)
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\erro
rhandling.py", line 71, in try_call
    return func(self, *args, **kw)
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\tool
box\designer\__init__.py", line 215, in save_state
    if name != session_file_name: name = self.save_session_as_name(name)
  File "c:\python24\lib\site-packages\TurboGears-1.0b1-py2.4.egg\turbogears\tool
box\designer\__init__.py", line 204, in save_session_as_name
    name = name.translate(string.maketrans('',''), string.punctuation)
TypeError: translate() takes exactly one argument (2 given)
Request Headers:
  COOKIE: tg-visit=2b777b57c302f63e302d9a0b20a8a357c648471b
  Content-Length: 175
  ACCEPT-CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  USER-AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/
20060728 Firefox/
  CONNECTION: keep-alive
  PRAGMA: no-cache
  HOST: localhost:7654
  CACHE-CONTROL: no-cache
  CONTENT-TYPE: application/x-www-form-urlencoded
  ACCEPT: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/pl
  ACCEPT-LANGUAGE: en-us,en;q=0.5
  Content-Type: application/x-www-form-urlencoded
  ACCEPT-ENCODING: gzip,deflate
  KEEP-ALIVE: 300 - - [10/Sep/2006:21:01:04] "POST /designer/save_state HTTP/1.1" 500 27
22 "" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2006072
8 Firefox/"

Change History

comment:1 Changed 13 years ago by douglaz

  • Severity changed from normal to major

I got the sample problem. This happens because name is a unicode string, so it don't need a translation table.

comment:2 Changed 13 years ago by jorge.vargas

  • Priority changed from normal to high
  • Component changed from Toolbox to Toolbox.ModelDesigner
  • Severity changed from major to critical
  • Milestone changed from 1.0b1 to 1.0b2

comment:3 Changed 13 years ago by roger.demetrescu

This little patch gets rid of the error, but I am not sure if it is the best solution (eg. if I try to save a session using "áéíóú" as the name, the file created has the name "áéíóú.js"):

  • turbogears/toolbox/designer/__init__.py

    201201    load_current_model= turbogears.expose(format='json')(load_current_model) 
    203203    def save_session_as_name(self,name): 
    204         name = name.translate(string.maketrans('',''), string.punctuation)  
     204        name = name.encode('utf8').translate(string.maketrans('',''), string.punctuation)  
    205205        name =  ''.join([x.title() for x in name.split()]) #camelcase to remove spaces 
    206206        sessions_directory = pkg_resources.resource_filename(__name__,os.path.join('static','sessions')) 
    207207        postfix = '' 

It does apply well if only 'ascii' names are used... :)

comment:4 Changed 12 years ago by alberto

  • Milestone changed from 1.0b2 to 1.1

comment:5 Changed 12 years ago by alberto

  • Milestone changed from 1.1 to __unclassified__

Batch moved into unclassified from 1.1 to properly track progress on the later

comment:6 Changed 10 years ago by jorge.vargas

  • Milestone changed from __unclassified__ to 1.x
  • Summary changed from Modeldesigner throws exception in save_state to [patch] Modeldesigner throws exception in save_state

comment:7 Changed 10 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in r6197.

Note: See TracTickets for help on using tickets.