Changeset 24
- Timestamp:
- 02/03/07 15:35:39 (6 years ago)
- Location:
- elixir/trunk
- Files:
-
- 16 added
- 8 modified
-
docs (added)
-
docs/about.rst (added)
-
docs/examples.rst (added)
-
docs/html (added)
-
docs/html/images (added)
-
docs/html/images/background.jpg (added)
-
docs/html/images/logo.jpg (added)
-
docs/index.rst (added)
-
docs/template (added)
-
docs/template/elixir.css (added)
-
docs/template/images (added)
-
docs/template/images/background.jpg (added)
-
docs/template/images/logo.jpg (added)
-
docs/template/layout.html (added)
-
docs/tutorial.rst (added)
-
elixir/__init__.py (modified) (3 diffs)
-
elixir/entity.py (modified) (2 diffs)
-
elixir/examples/__init__.py (modified) (1 diff)
-
elixir/fields.py (modified) (3 diffs)
-
elixir/options.py (modified) (1 diff)
-
elixir/relationships.py (modified) (1 diff)
-
elixir/statements.py (modified) (1 diff)
-
setup.cfg (added)
-
setup.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/elixir/__init__.py
r23 r24 1 1 ''' 2 Elixir 2 Elixir package 3 3 4 4 A declarative layer on top of SQLAlchemy, which is intended to replace the … … 12 12 not need the full expressiveness of SQLAlchemy's manual mapper definitions. 13 13 14 For an example of how to use Elixir, please refer to the examples directory and15 the unit tests. The examples directory includes a TurboGears application with 16 full identity support called 'videostore'.14 For an example of how to use Elixir, please refer to the examples directory 15 and the unit tests. The examples directory includes a TurboGears application 16 with full identity support called 'videostore'. 17 17 ''' 18 18 … … 52 52 53 53 def create_all(): 54 """Create all necessary tables for all declared entities"""54 'Create all necessary tables for all declared entities' 55 55 for md in metadatas: 56 56 md.create_all() 57 57 58 58 def drop_all(): 59 """Drop all tables for all declared entities"""59 'Drop all tables for all declared entities' 60 60 for md in metadatas: 61 61 md.drop_all() -
elixir/trunk/elixir/entity.py
r22 r24 19 19 class Entity(object): 20 20 ''' 21 The base class for all entities. All Elixir model objects should inherit 22 from this class. Statements can appear within the body of the definition 23 of an entity to define its fields, relationships, and other options. Here 24 is an example: 21 The base class for all entities 22 23 All Elixir model objects should inherit from this class. Statements can 24 appear within the body of the definition of an entity to define its 25 fields, relationships, and other options. 26 27 Here is an example: 28 29 :: 25 30 26 31 class Person(Entity): … … 28 33 has_field('birthdate', DateTime, default=datetime.now) 29 34 30 For further information, please refer to the provided examples or tutorial. 35 For further information, please refer to the provided examples or 36 tutorial. 31 37 ''' 32 38 -
elixir/trunk/elixir/examples/__init__.py
r1 r24 1 ''' 2 ======== 3 Examples 4 ======== 5 6 Contains various example projects. 7 ''' -
elixir/trunk/elixir/fields.py
r18 r24 11 11 class Field(object): 12 12 ''' 13 Represents the definition of a 'field' on an entity. In other words, this 14 class represents a column on the table where the entity is stored. This 15 object is only used with the 'with_fields' syntax for defining all fields 16 for an entity at the same time. The 'has_field' syntax does not require 17 the manual creation of this object. 13 Represents the definition of a 'field' on an entity. 14 15 This class represents a column on the table where the entity is stored. 16 This object is only used with the ``with_fields`` syntax for defining all 17 fields for an entity at the same time. The ``has_field`` syntax does not 18 require the manual creation of this object. 18 19 ''' 19 20 … … 42 43 class HasField(object): 43 44 ''' 44 Statement object for specifying a single field on an entity. The first 45 argument is the name of the field, the second is its type, and following 46 this any number of keyword arguments can be specified for additional 47 behavior. The keyword arguments are passed on to the SQLAlchemy 'Column' 48 object. Please refer to the SQLAlchemy 'Column' object's documentation for 49 further detail about which keyword arguments are supported. 45 Statement object for specifying a single field on an entity. 50 46 51 Here is a quick example of how to use 'has_field'. 47 The first argument is the name of the field, the second is its type, and 48 following this any number of keyword arguments can be specified for 49 additional behavior. The keyword arguments are passed on to the SQLAlchemy 50 ``Column`` object. Please refer to the SQLAlchemy ``Column`` object's 51 documentation for further detail about which keyword arguments are 52 supported. 53 54 Here is a quick example of how to use ``has_field``. 55 56 :: 52 57 53 58 class Person(Entity): … … 64 69 class WithFields(object): 65 70 ''' 66 Statement object for specifying all fields on an entity at once. Each 67 keyword argument to this statement represents one field, which should be 68 a Field object. The first argument to a Field object is its type, and 69 following this any number of keyword arguments can be specified for 70 additional behavior. The keyword arguments are passed on to the SQLAlchemy 71 'Column' object. Please refer to the SQLAlchemy 'Column' object's 72 documentation for further detail about which keyword arguments are 71 Statement object for specifying all fields on an entity at once. 72 73 Each keyword argument to this statement represents one field, which should 74 be a Field object. The first argument to a Field object is its type, and 75 following this any number of keyword arguments can be specified for 76 additional behavior. The keyword arguments are passed on to the SQLAlchemy 77 ``Column`` object. Please refer to the SQLAlchemy ``Column`` object's 78 documentation for further detail about which keyword arguments are 73 79 supported. 74 80 75 Here is a quick example of how to use 'with_fields'. 81 Here is a quick example of how to use ``with_fields``. 82 83 :: 76 84 77 85 class Person(Entity): -
elixir/trunk/elixir/options.py
r23 r24 14 14 more. To specify an option, simply supply the option as a keyword 15 15 argument onto the statement, as follows: 16 17 :: 16 18 17 19 class Person(Entity): -
elixir/trunk/elixir/relationships.py
r22 r24 1 1 ''' 2 ============= 3 Relationships 4 ============= 5 2 6 This module provides support for defining relationships between your Elixir 3 7 entities. The supported relationship types are as follows: 4 8 5 `belongs_to`6 ------------7 Describes the child's side of a parent-child relationship. For example,8 a `Pet` object may belong to its owner, who is a `Person.` This could be9 expressed like so:10 11 class Pet(Entity):12 belongs_to('owner', of_kind='Person', inverse='pets')13 14 You must specify the 'kind' of object that you are relating to using the15 of_kind keyword argument. Additionally, if you plan on defining the other16 side of the relationship, you should specify the name of the relationship17 on the other side using the 'inverse' keyword argument.18 19 20 `has_one`21 ---------22 TODO.23 24 25 `has_many`26 ----------27 TODO.28 29 30 `has_and_belongs_to_many`31 -------------------------32 TODO.9 `belongs_to` 10 ------------ 11 Describes the child's side of a parent-child relationship. For example, 12 a `Pet` object may belong to its owner, who is a `Person.` This could be 13 expressed like so: 14 15 class Pet(Entity): 16 belongs_to('owner', of_kind='Person', inverse='pets') 17 18 You must specify the 'kind' of object that you are relating to using the 19 of_kind keyword argument. Additionally, if you plan on defining the other 20 side of the relationship, you should specify the name of the relationship 21 on the other side using the 'inverse' keyword argument. 22 23 24 `has_one` 25 --------- 26 TODO. 27 28 29 `has_many` 30 ---------- 31 TODO. 32 33 34 `has_and_belongs_to_many` 35 ------------------------- 36 TODO. 33 37 ''' 34 38 -
elixir/trunk/elixir/statements.py
r17 r24 1 1 class Statement(object): 2 2 ''' 3 A 'statement' object represents a DSL term. 3 DSL-style syntax 4 5 A ``Statement`` object represents a DSL term. 4 6 ''' 5 7 -
elixir/trunk/setup.py
r17 r24 1 from setuptools import setup, find_packages 2 1 3 classifiers = """ 2 4 "Development Status :: 3 - Alpha", … … 9 11 """ 10 12 11 from setuptools import setup, find_packages12 13 13 setup(name="Elixir", 14 14 version="0.0.1", 15 15 description="Declarative Mapper for SQLAlchemy", 16 long_description=""" 17 Elixir 18 ====== 19 20 A declarative layer on top of SQLAlchemy, which is intended to replace the 21 ActiveMapper SQLAlchemy extension, and the TurboEntity project. Elixir is a 22 fairly thin wrapper around SQLAlchemy, which provides the ability to define 23 model objects following the Active Record design pattern, and using a DSL 24 syntax similar to that of the Ruby on Rails ActiveRecord system. 25 26 Elixir does not intend to replace SQLAlchemy's core features, but instead 27 focuses on providing a simpler syntax for defining model objects when you do 28 not need the full expressiveness of SQLAlchemy's manual mapper definitions. 29 """, 16 30 author="", 17 31 author_email="", … … 23 37 'elixir.tests'], 24 38 classifiers=classifiers, 39 extras_require = { 40 'pudge': ["docutils>=0.4", "elementtree>=1.2.6", "kid>=0.9", 41 "Pygments==dev,>=0.7dev-r2661", "pudge==dev,>=0.1.3dev-r134", 42 "buildutils==dev,>=0.1.2dev-r109",], 43 }, 25 44 test_suite = 'nose.collector')
