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 #2122 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

[PATCH] catwalk (in sprox.saormprovider) fails when including user in group creation

Reported by: clemens Owned by: percious
Priority: normal Milestone: 2.0b2
Component: TurboGears Version: trunk
Severity: normal Keywords: catwalk sprox
Cc:

Description

Action:

  • new virtualenv --no-site-packages on Ubuntu 8.10
  • cd tg_env; source bin/activate
  • fresh install of tg-2.0b1 following  http://www.turbogears.org/2.0/docs/main/DownloadInstall.html
  • paster quickstart demo # with auth
  • cd demo
  • paster setup-app development.ini
  • paster serve development.ini
  • browse to localhost:8080
  • login
  • browse to /admin
  • select "Group"
  • select "add"
  • enter "newgroup" "newgroup" manager
  • click "Submit"

Expected result:

  • group "newgroup" added with member manager

Actual result: InvalidRequestError?: Invalid column expression '<function return_cls at 0xa06617c>'

Selecting permissions during group creation works fine if I don't also select a User.

Traceback: Module catwalk.tg2.controller:137 in create view << params = pylons.request.params.copy()

self.provider.create(model, params=kw) raise redirect('../')

self.provider.create(model, params=kw)

Module sprox.saormprovider:220 in create view << setattr(obj, key, value)

self.session.add(obj) self.create_relationships(obj, params) self.session.flush() return obj

self.create_relationships(obj, params)

Module sprox.saormprovider:205 in create_relationships view << for value in params[relation]:

if value is not None:

target_obj = self.session.query(target).get(value) if target_obj is not None:

if prop.uselist:

target_obj = self.session.query(target).get(value)

Module sqlalchemy.orm.scoping:121 in do view << def instrument(name):

def do(self, *args, kwargs):

return getattr(self.registry(), name)(*args, kwargs)

return do

for meth in Session.public_methods:

return getattr(self.registry(), name)(*args, kwargs)

Module sqlalchemy.orm.session:908 in query view << """Return a new Query object corresponding to this Session."""

return self._query_cls(entities, self, kwargs)

def _autoflush(self):

return self._query_cls(entities, self, kwargs)

Module sqlalchemy.orm.query:93 in init view << for ent in util.to_list(entities):

_QueryEntity(self, ent)

self.setup_aliasizers(self._entities)

_QueryEntity(self, ent)

Module sqlalchemy.orm.query:1778 in init view << column = column.clause_element()

elif not isinstance(column, sql.ColumnElement?):

raise sa_exc.InvalidRequestError?("Invalid column expression '%r'" % column)

else:

self._result_label = getattr(column, 'key', None)

raise sa_exc.InvalidRequestError?("Invalid column expression '%r'" % column)

InvalidRequestError?: Invalid column expression '<function return_cls at 0xa06617c>'

Attachments

saormprovider.py.patch Download (1.1 KB) - added by clemens 10 years ago.
patch against sprox/saormprovider.py (tip)

Change History

comment:1 Changed 10 years ago by clemens

Replicated the problem in trunk (r5996).

comment:2 Changed 10 years ago by mramm

  • Version changed from 1.9.x to trunk
  • Milestone set to 2.0b2

comment:3 Changed 10 years ago by mramm

Changed 10 years ago by clemens

patch against sprox/saormprovider.py (tip)

comment:4 Changed 10 years ago by clemens

  • Summary changed from catwalk (in sprox.saormprovider) fails when including user in group creation to [PATCH] catwalk (in sprox.saormprovider) fails when including user in group creation

catwalk gets the relation object via the mapper using various ways. Some of the properties returned by the mapper have arguments that can be queried directly, others return a function that must be called. After finding 3 different objects returned (Mapper, return_cls function and a third I've forgotten), I gave up enumerating them. The patch above just tests if we have a function and calls it. It works around the problem, but is probably optimistic and somewhat fragile. I also haven't yet delved into how to write a test for this error. (It also doesn't address #2123)

comment:5 Changed 10 years ago by mramm

  • Owner changed from faide to percious

comment:6 Changed 10 years ago by percious

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.