Hi, I tried the patch, but got the following error :
/home/cdevienne/prog/sqlalchemy/lib/sqlalchemy/ext/declarative.pyc in decorate(fn) 645 """ 646 def decorate(fn): --> 647 return util.update_wrapper(_orm_synonym(name, map_column=map_column, descriptor=fn), fn) 648 return decorate 649 /usr/lib/python2.5/functools.pyc in update_wrapper(wrapper, wrapped, assigned, updated) 31 """ 32 for attr in assigned: ---> 33 setattr(wrapper, attr, getattr(wrapped, attr)) 34 for attr in updated: 35 getattr(wrapper, attr).update(getattr(wrapped, attr, {})) AttributeError: 'property' object has no attribute '__module__' I think the problem is, in that case, that the decorator is applied on property, not a function. I also tried to do the following : def decorate(fn): w = _orm_synonym(name, map_column=map_column, descriptor=fn) w.__doc__ = fn.__doc__ return w return decorate But in my documentation, I get "A combination of InsturmentedAttribute and a regular descriptor.", which is the docstring of a Proxy class defined in proxied_attribute_factory, in attributes.py. >From what I could understand, at one moment the attributes.register_descriptor function replace my property on the class, and it is seems to be at that moment that the docstring is lost. I might be completely wrong though, it is just a guess. Thanks, Chrisotphe 2009/6/12 Michael Bayer <mike...@zzzcomputing.com> > > try this patch: > > Index: lib/sqlalchemy/ext/declarative.py > =================================================================== > --- lib/sqlalchemy/ext/declarative.py (revision 6051) > +++ lib/sqlalchemy/ext/declarative.py (working copy) > @@ -639,8 +639,9 @@ > prop = synonym('col', descriptor=property(_read_prop, _write_prop)) > > """ > + > def decorate(fn): > - return _orm_synonym(name, map_column=map_column, descriptor=fn) > + return util.update_wrapper(_orm_synonym(name, > map_column=map_column, descriptor=fn), fn) > return decorate > > def comparable_using(comparator_factory): > @@ -661,7 +662,7 @@ > > """ > def decorate(fn): > - return comparable_property(comparator_factory, fn) > + return > util.update_wrapper(comparable_property(comparator_factory, fn), fn) > return decorate > > def _declarative_constructor(self, **kwargs): > > > > Angri wrote: > > > > I think that patch which you would like to provide could add > > functools.wraps decorator to the decorator defined in synonym_for(). > > See http://docs.python.org/library/functools.html#functools.wraps > > > > -- > > Anton Gritsay > > http://angri.ru > > > > On 12 ÉÀÎ, 22:20, Christophe de VIENNE <cdevie...@gmail.com> wrote: > >> Hi, > >> > >> I noticed that when I use the @synonym_for decorator, my function > >> docstring > >> get lost. > >> > >> I got lost in SA code around the attributes.register_descriptor > >> function, > >> which is one of the steps I guess the doc is not copied (along with the > >> decorator function itself), and cannot propose a patch. > >> > >> I workaround the issue by doing the plain synonym declaration and using > >> the > >> sphinx specific docstrings for class attributes, but it would be really > >> great if it could just work. > >> > >> And thanks for the awesome tool SqlAlchemy is : it is a constant source > >> of > >> amazement to me. > >> > >> Regards, > >> > >> Christophe > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. 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 -~----------~----~----~----~------~----~------~--~---