1 """
2 pyperry
3 =======
4
5 pyperry is an ORM designed to interface with a datastore through an abstract
6 interface. Rather than building SQL queries itself, queries are built in a
7 generic way that can be interpreted by an adapter and converted to any desired
8 query interface (like SQL, or any domain specific language). Adapter results
9 are mapped to instances of L{pyperry.base.Base}.
10
11 Documentation Overview
12 ----------------------
13
14 - Defining models, Querying, and Persistence: L{pyperry.base.Base}
15 - Adapter Configuration: L{pyperry.adapter}
16
17 Basic Usage
18 -----------
19
20 This is an example of a Person model::
21
22 class Person(pyperry.base.Base):
23 def config(cls):
24 # Define attributes
25 cls.attributes('id', 'name', 'favorite_color')
26
27 # Basic adapter configuration
28 cls.configure('read', type='bertrpc', procedure='person')
29 cls.add_middleware('read', MyMiddleware, config='val')
30
31 # Associations
32 cls.has_one('address', class_name='Address')
33
34 # Example of defining scopes
35 cls.scope('ordered', cls.order('order_by'))
36 @cls.scope
37 def name_like(word):
38 return cls.where('asset.`name` LIKE '"%%s%"' % word))
39
40 # ...
41
42 Some example usage:
43
44 >>> bob = Person({ 'name': 'Bob' })
45 >>> bob.name
46 'Bob'
47 >>> bob.save()
48 True
49 >>> perry = Person.where({ 'name': 'Perry' }).first()
50 >>> perry.name
51 'Perry'
52 >>> perry.address()
53 #<Address ...>
54
55 For detailed documentation on these methods see:
56
57 - L{pyperry.base.Base.attributes}
58 - Adapter Configuration
59 - L{Base.configure}
60 - L{Base.add_middleware}
61 - Associations
62 - L{pyperry.base.Base.has_many}
63 - L{pyperry.base.Base.has_one}
64 - L{pyperry.base.Base.belongs_to}
65 - L{pyperry.base.Base.scope}
66
67 """
68
69 from pyperry.base import Base
70 from pyperry.relation import Relation
71 from pyperry.association import Association
72 import logging
73
74
75 logger = logging
76