Here is the paste.

http://pastebin.com/MzLNWUw2 

1) rational for using synonym_for: the sqlajqgrid of toscawidgets2 
(http://tw2-demos.threebean.org/module?module=tw2.jqplugins.jqgrid) uses 

sqlalchemy.orm.class_mapper(cls.entity).iterate_properties which does not show
defined attributs/memoized_property column (like total_sales in code). But when 
I use synonym_for
it displays that column.

2) It uses default sorters/comparators of sqlalchemy but those does not work on 
total_sales field 
producing the same traceback just as you get when running this example.

It seems like it searches for some comparator sort of things for total_sales 
but I am not able to 
get the hang of it.

On Sunday, 26 August 2012 07:32:59 UTC+5:30, Michael Bayer wrote:
>
>
> On Aug 25, 2012, at 4:48 PM, jeetu wrote: 
>
> > I have a sqlalchemy table defined like follows 
> > 
> > class Album(DeclarativeBase): 
> > 
> >     # Name of mapped db table 
> >     __tablename__ = 'material' 
> >     id = Column(Integer, primary_key=True) 
> >     name = Column(Unicode(50), nullable=False, unique=True) 
> >     
> >     @synonym_for("_voltage") 
> >     @memoized_property 
> >     def total_sales(self): 
> >         do some calculation here 
> >         return result 
> > 
> > For some reasons(showing it in sqlajqgrid of tw2) I am using 
> synonym_for. Now when I try to use the sorting/comparisons which inturn 
> calls for same functions of sqlalchemy. it does not work. It gives a long 
> traceback with statements like 
> > 
> >     return getattr(self.comparator, attribute) 
> >   File 
> "/home/jeetu/LEARN/turbogears/tg22_venv/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7-linux-x86_64.egg/sqlalchemy/util/langhelpers.py",
>  
> line 485, in __get__ 
> >     obj.__dict__[self.__name__] = result = self.fget(obj) 
> >   File 
> "/home/jeetu/LEARN/turbogears/tg22_venv/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7-linux-x86_64.egg/sqlalchemy/orm/attributes.py",
>  
> line 203, in comparator 
> >     self._comparator = self._comparator() 
> >   File 
> "/home/jeetu/LEARN/turbogears/tg22_venv/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7-linux-x86_64.egg/sqlalchemy/orm/descriptor_props.py",
>  
> line 67, in <lambda> 
> >     lambda: self._comparator_factory(mapper), 
> >   File 
> "/home/jeetu/LEARN/turbogears/tg22_venv/local/lib/python2.7/site-packages/SQLAlchemy-0.7.8-py2.7-linux-x86_64.egg/sqlalchemy/orm/descriptor_props.py",
>  
> line 376, in _comparator_factory 
> >     prop = self._proxied_property 
> > RuntimeError: maximum recursion depth exceeded while calling a Python 
> object 
> > 
> > As to my understanding it is searching for comparator function but not 
> able to find one. I tried implementing some sort of PropComparator, 
> ColumnComparator etc, but not able to get it rigth. Can somebody help me to 
> get the sorting function implemented. 
>
>
> I'd need a full example that reproduces this (which means, a single .py 
> file I can copy locally, and run it. ).   the above snippet doesn't include 
> any detail, such as what "_voltage" is, what the comparator looks like, 
> etc. 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/5IO5C_zCQ2QJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to