zopefoundation / Products.SQLAlchemyDA

SQLAlchemyDA is a generic database adapter for ZSQL methods. Since it is based on SQLAlchemy, SQLAlchemyDA supports all databases out-of-the box that are supported by SQLAlchemy (Postgres, MySQL, Oracle, SQLite, MS-SQL, Firebird, Informix).
Other
2 stars 10 forks source link

Avoid Expression Error in the info.zpt template #2

Closed cleberjsantos closed 7 years ago

cleberjsantos commented 10 years ago

ExpressionError: Not a valid path-expression.

 - String:     "info_d/?k"
 - Filename:   manage_workspace

 - Expression: "info_d/?k"
 - Filename:   manage_workspace
 - Location:   (0:1338)
 - Arguments:  repeat: {...} (0)

cleberjsantos commented 10 years ago

@zopyx @ctheune

ctheune commented 10 years ago

Uh, sorry. Not having touched this in ages. Not going to do so either anymore.

tseaver commented 10 years ago

How are you provoking this bug? 'DA.getInfo' returns a dict, period.

https://github.com/zopefoundation/Products.SQLAlchemyDA/blob/14a97eb30756d3d8f533ad4cfefa0bf97dec157e/Products/SQLAlchemyDA/da.py#L126

cleberjsantos commented 10 years ago

@tseaver We have two problems.

1- The problem are the call in the template

-- <td class="list-item" tal:content="info_d/?k" />
++ <td class="list-item" tal:content="python: info_d[k]" />

The line 37 cannot be ?k, is necessary be a dict call.

2 - After fix the first problem,then:

After the call of key k, the output also's a dict, eg.

(Pdb) da.getInfo()
{'username': None, 'extension_options': {'initial_state': 'invalidated'}, 'DSN': 'sqlite:///test', 'host': None, 'twophase': False, 'session_options': {}, 'drivername': 'sqlite', 'password': None, 'dbname': 'test', 'engine_options': {'convert_unicode': 0, 'encoding': 'iso-8859-15'}, 'url': sqlite:///test, 'transactional': True, 'port': None, 'dsn': 'sqlite:///test'}

Look the keys extension_options, engine_options, returning a dict. In the template does not treated for show results this.

jordic commented 7 years ago

Found same bug! It appears when switched to five.pt and chameleon templates... @tseaver
(Seems like it don't likes the info_d/?k) path traverser. Can we fix it? Should I send a new and updated PR?

cleberjsantos commented 7 years ago

@jordic I have a fix here: https://github.com/zopefoundation/Products.SQLAlchemyDA/pull/2/commits/876cefc15e1f417c158447bb2b9b27561f45e6e2 and I have used it in production without problems

icemac commented 7 years ago

@jordic An updated PR would be nice.

tseaver commented 7 years ago

Superseded by #4.