Ticket #491 (closed defect: fixed)

Opened 12 months ago

Last modified 12 months ago

Support for SQLAlchemy synonym properties

Reported by: nick Owned by: nick
Priority: major Milestone: 0.4.2
Component: Adapter Version: 0.4.1
Keywords: sqlalchemy Cc:
Fixed in revision: Branch: pyamf/branches/sqlalchemy-properties-491
Author: nick

Description (last modified by nick) (diff)

See the  mailing list for reference.

class Contact(Base):
    __tablename__ = "org_contacts"

    id = Column(Integer, primary_key = True)
    short_name = Column(Unicode(20), index = True)
    first_name = Column(Unicode(50))
    last_name = Column(Unicode(50))
    email_address = Column(Unicode(50))
    notes = Column(UnicodeText)
    organization_id = Column(Integer, ForeignKey("org_organizations.id"))
    modified = Column(DateTime, default=datetime.now, onupdate = datetime.now)
    modified_by_id = Column(Integer, ForeignKey("app_users.id"))
    inactive = Column(Boolean, default=False)

    organization = relation("Organization", lazy = False)
    phones = relation("Phone", lazy = True)
    modified_by = relation("User", lazy = False)

   # This is what I want to do:
##    @synonym_for("short_name")
##    @property
##    def display_name(self):
##        inact = "*" if self.inactive else ""
##        return inact + self.short_name
##

   # This works but is harder to do:
    display_name = column_property(
        (case([(inactive, u"*")], else_ = u"") + short_name
            ).label("display_name"))

Change History

Changed 12 months ago by nick

  • description modified (diff)

Changed 12 months ago by nick

  • keywords review added
  • owner changed from nick to thijs
  • status changed from new to assigned

I have added support for @property types in the sqlalchemy adapter.

Changed 12 months ago by nick

  • branch set to pyamf/branches/sqlalchemy-properties-491
  • author set to nick

Changed 12 months ago by thijs

looks good, please merge if the feedback from the mailinglist was positive.

Changed 12 months ago by nick

  • keywords review removed
  • owner changed from thijs to nick
  • status changed from assigned to accepted

The feedback was positive for this particular issue but there are other issues to be addressed with other tickets.

Changed 12 months ago by nick

  • status changed from accepted to closed
  • resolution set to fixed
  • description modified (diff)
Note: See TracTickets for help on using tickets.