Changeset 82 for elixir/trunk/elixir/__init__.py
- Timestamp:
- 03/05/07 18:03:08 (6 years ago)
- Files:
-
- 1 modified
-
elixir/trunk/elixir/__init__.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/elixir/__init__.py
r73 r82 1 1 ''' 2 2 Elixir package 3 3 4 4 A declarative layer on top of SQLAlchemy, which is intended to replace the 5 5 ActiveMapper SQLAlchemy extension, and the TurboEntity project. Elixir is a 6 fairly thin wrapper around SQLAlchemy, which provides the ability to define 7 model objects following the Active Record design pattern, and using a DSL 6 fairly thin wrapper around SQLAlchemy, which provides the ability to define 7 model objects following the Active Record design pattern, and using a DSL 8 8 syntax similar to that of the Ruby on Rails ActiveRecord system. 9 9 10 Elixir does not intend to replace SQLAlchemy's core features, but instead 10 Elixir does not intend to replace SQLAlchemy's core features, but instead 11 11 focuses on providing a simpler syntax for defining model objects when you do 12 12 not need the full expressiveness of SQLAlchemy's manual mapper definitions. … … 31 31 from sets import Set as set 32 32 33 __all__ = ['Entity', 'Field', 'has_field', 'with_fields', 34 'belongs_to', 'has_one', 'has_many', 'has_and_belongs_to_many', 33 __all__ = ['Entity', 'Field', 'has_field', 'with_fields', 34 'belongs_to', 'has_one', 'has_many', 'has_and_belongs_to_many', 35 35 'using_options', 'using_table_options', 'using_mapper_options', 36 36 'options_defaults', 'metadata', 'objectstore', 37 'create_all', 'drop_all', 'setup_all', 'cleanup_all', 37 'create_all', 'drop_all', 'setup_all', 'cleanup_all', 38 38 'delay_setup'] + \ 39 39 sqlalchemy.types.__all__ … … 51 51 # thread local SessionContext 52 52 class Objectstore(object): 53 53 54 def __init__(self, *args, **kwargs): 54 55 self.context = SessionContext(*args, **kwargs) 56 55 57 def __getattr__(self, name): 56 58 return getattr(self.context.current, name) 57 59 session = property(lambda s:s.context.current) 58 60 59 61 objectstore = Objectstore(sqlalchemy.create_session) 60 62 61 63 metadatas = set() 64 62 65 63 66 def create_all(): … … 65 68 for md in metadatas: 66 69 md.create_all() 70 67 71 68 72 def drop_all(): … … 74 78 delay_setup = False 75 79 80 76 81 def setup_all(): 77 82 '''Setup the table and mapper for all entities which have been delayed. 78 83 79 84 This should be used in conjunction with setting ``delay_setup`` to ``True`` 80 85 before defining your entities. … … 95 100 create_all() 96 101 102 97 103 def cleanup_all(): 98 104 '''Drop table and clear mapper for all entities, and clear all metadatas.
