From: Mike Bayer Date: Sat, 10 May 2008 00:31:09 +0000 (+0000) Subject: removed deprecated plugins docs X-Git-Tag: rel_0_5beta1~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fcc995b9deca7b60c76784109cec0935e45b844;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git removed deprecated plugins docs --- diff --git a/doc/build/content/plugins.txt b/doc/build/content/plugins.txt index c144826d7b..b0eb4ad425 100644 --- a/doc/build/content/plugins.txt +++ b/doc/build/content/plugins.txt @@ -556,144 +556,3 @@ SqlSoup creates mapped classes on the fly from tables, which are automatically r Full SqlSoup documentation is on the [SQLAlchemy Wiki](http://www.sqlalchemy.org/trac/wiki/SqlSoup). - -### Deprecated Extensions - -A lot of our extensions are deprecated. But this is a good thing. Why ? Because all of them have been refined and focused, and rolled into the core of SQLAlchemy. So they aren't removed, they've just graduated into fully integrated features. Below we describe a set of extensions which are present in 0.4 but are deprecated. - -#### SelectResults - -**Author:** Jonas Borgström - -*NOTE:* As of version 0.3.6 of SQLAlchemy, most behavior of `SelectResults` has been rolled into the base `Query` object. Explicit usage of `SelectResults` is therefore no longer needed. - -`SelectResults` gives transformative behavior to the results returned from the `select` and `select_by` methods of `Query`. - - {python} - from sqlalchemy.ext.selectresults import SelectResults - - query = session.query(MyClass) - res = SelectResults(query) - - res = res.filter(table.c.column == "something") # adds a WHERE clause (or appends to the existing via "and") - res = res.order_by([table.c.column]) # adds an ORDER BY clause - - for x in res[:10]: # Fetch and print the top ten instances - adds OFFSET 0 LIMIT 10 or equivalent - print x.column2 - - # evaluate as a list, which executes the query - x = list(res) - - # Count how many instances that have column2 > 42 - # and column == "something" - print res.filter(table.c.column2 > 42).count() - - # select() is a synonym for filter() - session.query(MyClass).select(mytable.c.column=="something").order_by([mytable.c.column])[2:7] - -An important facet of SelectResults is that the actual SQL execution does not occur until the object is used in a list or iterator context. This means you can call any number of transformative methods (including `filter`, `order_by`, list range expressions, etc) before any SQL is actually issued. - -Configuration of SelectResults may be per-Query, per Mapper, or per application: - - {python} - from sqlalchemy.ext.selectresults import SelectResults, SelectResultsExt - - # construct a SelectResults for an individual Query - sel = SelectResults(session.query(MyClass)) - - # construct a Mapper where the Query.select()/select_by() methods will return a SelectResults: - mapper(MyClass, mytable, extension=SelectResultsExt()) - - # globally configure all Mappers to return SelectResults, using the "selectresults" mod - import sqlalchemy.mods.selectresults - -SelectResults greatly enhances querying and is highly recommended. For example, heres an example of constructing a query using a combination of joins and outerjoins: - - {python} - mapper(User, users_table, properties={ - 'orders':relation(mapper(Order, orders_table, properties={ - 'items':relation(mapper(Item, items_table)) - })) - }) - session = create_session() - query = SelectResults(session.query(User)) - - result = query.outerjoin_to('orders').outerjoin_to('items').select(or_(Order.c.order_id==None,Item.c.item_id==2)) - -For a full listing of methods, see the [generated documentation](rel:docstrings_sqlalchemy.ext.selectresults). - -#### SessionContext - -**Author:** Daniel Miller - -The `SessionContext` extension is still available in the 0.4 release of SQLAlchemy, but has been deprecated in favor of the [scoped_session()](rel:unitofwork_contextual) function, which provides a class-like object that constructs a `Session` on demand which references a thread-local scope. - -For docs on `SessionContext`, see the SQLAlchemy 0.3 documentation. - -#### assignmapper - -**Author:** Mike Bayer - -The `assignmapper` extension is still available in the 0.4 release of SQLAlchemy, but has been deprecated in favor of the [scoped_session()](rel:unitofwork_contextual) function, which provides a `mapper` callable that works similarly to `assignmapper`. - -For docs on `assignmapper`, see the SQLAlchemy 0.3 documentation. - -#### ActiveMapper - -**Author:** Jonathan LaCour - -Please note that ActiveMapper has been deprecated in favor of either [Elixir](http://elixir.ematia.de/), a comprehensive solution to declarative mapping, or [declarative](rel:plugins_declarative), a built in convenience tool which reorganizes `Table` and `mapper()` configuration. - -ActiveMapper is a so-called "declarative layer" which allows the construction of a class, a `Table`, and a `Mapper` all in one step: - - {python} - class Person(ActiveMapper): - class mapping: - id = column(Integer, primary_key=True) - full_name = column(String) - first_name = column(String) - middle_name = column(String) - last_name = column(String) - birth_date = column(DateTime) - ssn = column(String) - gender = column(String) - home_phone = column(String) - cell_phone = column(String) - work_phone = column(String) - prefs_id = column(Integer, foreign_key=ForeignKey('preferences.id')) - addresses = one_to_many('Address', colname='person_id', backref='person') - preferences = one_to_one('Preferences', colname='pref_id', backref='person') - - def __str__(self): - s = '%s\n' % self.full_name - s += ' * birthdate: %s\n' % (self.birth_date or 'not provided') - s += ' * fave color: %s\n' % (self.preferences.favorite_color or 'Unknown') - s += ' * personality: %s\n' % (self.preferences.personality_type or 'Unknown') - - for address in self.addresses: - s += ' * address: %s\n' % address.address_1 - s += ' %s, %s %s\n' % (address.city, address.state, address.postal_code) - - return s - - - class Preferences(ActiveMapper): - class mapping: - __table__ = 'preferences' - id = column(Integer, primary_key=True) - favorite_color = column(String) - personality_type = column(String) - - - class Address(ActiveMapper): - class mapping: - id = column(Integer, primary_key=True) - type = column(String) - address_1 = column(String) - city = column(String) - state = column(String) - postal_code = column(String) - person_id = column(Integer, foreign_key=ForeignKey('person.id')) - -More discussion on ActiveMapper can be found at [Jonathan LaCour's Blog](http://cleverdevil.org/computing/35/declarative-mapping-with-sqlalchemy) as well as the [SQLAlchemy Wiki](http://www.sqlalchemy.org/trac/wiki/ActiveMapper). -