1 |
<? |
<?php |
2 |
/* |
|
3 |
## ------------------------------------------------------------------------------------- |
/** |
4 |
## $Id$ |
* ------------------------------------------------------------------------- |
5 |
## ------------------------------------------------------------------------------------- |
* $Id$ |
6 |
## $Log$ |
* ------------------------------------------------------------------------- |
7 |
## Revision 1.2 2003/02/13 21:48:09 joko |
* $Log$ |
8 |
## + caching mechanisms more configurable now |
* Revision 1.3 2003/03/01 04:56:38 joko |
9 |
## |
* new comment style for large blocks - stolen from phpHtmlLib |
10 |
## Revision 1.1 2003/02/09 17:23:21 joko |
* commit-log encapsulated into such a block |
11 |
## + refactored from flib/Application/RPC/ProxyObject.php |
* introduced some documentation |
12 |
## |
* refactored todo (now also inside a stylish block) |
13 |
## Revision 1.7 2003/02/03 03:31:38 jonen |
* |
14 |
## - moved '$encoder->toISO()' to 'Remote.php' |
* Revision 1.2 2003/02/13 21:48:09 joko |
15 |
## |
* + caching mechanisms more configurable now |
16 |
## Revision 1.6 2002/12/22 13:26:20 jonen |
* |
17 |
## + added support of tangram independent id (e.g. Data::UUID) toggled by option at conrtuctor |
* Revision 1.1 2003/02/09 17:23:21 joko |
18 |
## |
* + refactored from flib/Application/RPC/ProxyObject.php |
19 |
## Revision 1.5 2002/12/18 22:36:49 jonen |
* |
20 |
## + added support to get remote objects via backend via 'guid' |
* Revision 1.7 2003/02/03 03:31:38 jonen |
21 |
## + renamed '_loadBackend' to '_loadRemote' |
* - moved '$encoder->toISO()' to 'Remote.php' |
22 |
## + constructor now accepts additional options: |
* |
23 |
## + remote: try to get object via '_loadRemote' ... |
* Revision 1.6 2002/12/22 13:26:20 jonen |
24 |
## + oid: use the given identifier as an 'oid' when doing '_loadRemote' |
* + added support of tangram independent id (e.g. Data::UUID) toggled by option at conrtuctor |
25 |
## + guid: use the given identifier as a 'guid' when doing '_loadRemote' |
* |
26 |
## |
* Revision 1.5 2002/12/18 22:36:49 jonen |
27 |
## Revision 1.4 2002/12/12 02:46:31 joko |
* + added support to get remote objects via backend via 'guid' |
28 |
## + state (session) gets flushed when data was successfully loaded from remote side |
* + renamed '_loadBackend' to '_loadRemote' |
29 |
## + fixed _loadBackend |
* + constructor now accepts additional options: |
30 |
## + fixed flushState |
* + remote: try to get object via '_loadRemote' ... |
31 |
## |
* + oid: use the given identifier as an 'oid' when doing '_loadRemote' |
32 |
## Revision 1.3 2002/12/06 04:12:54 joko |
* + guid: use the given identifier as a 'guid' when doing '_loadRemote' |
33 |
## + replaced 'xyzCache' through 'xyzProxy' |
* |
34 |
## + function store(...) |
* Revision 1.4 2002/12/12 02:46:31 joko |
35 |
## |
* + state (session) gets flushed when data was successfully loaded from remote side |
36 |
## Revision 1.2 2002/12/05 21:44:09 joko |
* + fixed _loadBackend |
37 |
## + debugging |
* + fixed flushState |
38 |
## |
* |
39 |
## Revision 1.1 2002/12/01 17:23:58 joko |
* Revision 1.3 2002/12/06 04:12:54 joko |
40 |
## + initial check-in |
* + replaced 'xyzCache' through 'xyzProxy' |
41 |
## |
* + function store(...) |
42 |
## Revision 1.11 2002/11/12 06:05:58 cvsjoko |
* |
43 |
## + renamed class: Text_Encode -> TextEncode |
* Revision 1.2 2002/12/05 21:44:09 joko |
44 |
## |
* + debugging |
45 |
## Revision 1.10 2002/10/29 19:15:33 cvsjoko |
* |
46 |
## - moved utf8/iso-conversion to lib/utils/Text_Encode.php |
* Revision 1.1 2002/12/01 17:23:58 joko |
47 |
## |
* + initial check-in |
48 |
## Revision 1.9 2002/10/26 12:32:36 cvsjoko |
* |
49 |
## - removed debugging via "print" |
* Revision 1.11 2002/11/12 06:05:58 cvsjoko |
50 |
## + added generic logging via PEAR::Log |
* + renamed class: Text_Encode -> TextEncode |
51 |
## |
* |
52 |
## Revision 1.8 2002/10/22 09:51:38 cvsmax |
* Revision 1.10 2002/10/29 19:15:33 cvsjoko |
53 |
## + moved semi-method 'createBackend' to method $site->user->create at User.class.php |
* - moved utf8/iso-conversion to lib/utils/Text_Encode.php |
54 |
## |
* |
55 |
## Revision 1.7 2002/10/21 18:27:09 cvsjoko |
* Revision 1.9 2002/10/26 12:32:36 cvsjoko |
56 |
## - manually disabled any form of caching |
* - removed debugging via "print" |
57 |
## |
* + added generic logging via PEAR::Log |
58 |
## Revision 1.6 2002/10/17 03:48:47 cvsmax |
* |
59 |
## + new |
* Revision 1.8 2002/10/22 09:51:38 cvsmax |
60 |
## + function _createBackend create new Backend |
* + moved semi-method 'createBackend' to method $site->user->create at User.class.php |
61 |
## + function _create api-create |
* |
62 |
## |
* Revision 1.7 2002/10/21 18:27:09 cvsjoko |
63 |
## Revision 1.5 2002/10/16 03:37:54 cvsjoko |
* - manually disabled any form of caching |
64 |
## + bugfix: wrong comparison in restriction to save to array |
* |
65 |
## |
* Revision 1.6 2002/10/17 03:48:47 cvsmax |
66 |
## Revision 1.4 2002/10/10 03:04:23 cvsjoko |
* + new |
67 |
## + no debug-output |
* + function _createBackend create new Backend |
68 |
## |
* + function _create api-create |
69 |
## Revision 1.3 2002/10/10 03:03:27 cvsjoko |
* |
70 |
## + bugfix: save object to cache only if payload from backend isn't empty |
* Revision 1.5 2002/10/16 03:37:54 cvsjoko |
71 |
## |
* + bugfix: wrong comparison in restriction to save to array |
72 |
## Revision 1.2 2002/10/10 02:40:06 cvsjoko |
* |
73 |
## + new level of data-caching (session and persistant) |
* Revision 1.4 2002/10/10 03:04:23 cvsjoko |
74 |
## + function _loadState loads data from session |
* + no debug-output |
75 |
## + function _saveState saves data to session |
* |
76 |
## + function save api-save (session & backend) |
* Revision 1.3 2002/10/10 03:03:27 cvsjoko |
77 |
## + function _commit saves data to backend |
* + bugfix: save object to cache only if payload from backend isn't empty |
78 |
## + handy utils |
* |
79 |
## + function _setAttributes |
* Revision 1.2 2002/10/10 02:40:06 cvsjoko |
80 |
## + function flushState |
* + new level of data-caching (session and persistant) |
81 |
## |
* + function _loadState loads data from session |
82 |
## Revision 1.1 2002/10/09 00:51:39 cvsjoko |
* + function _saveState saves data to session |
83 |
## + new |
* + function save api-save (session & backend) |
84 |
## ------------------------------------------------------------------------------------- |
* + function _commit saves data to backend |
85 |
*/ |
* + handy utils |
86 |
|
* + function _setAttributes |
87 |
// TODO: |
* + function flushState |
88 |
// - make database connection more configurable to make possible |
* |
89 |
// to have different proxy database (besides the main database) |
* Revision 1.1 2002/10/09 00:51:39 cvsjoko |
90 |
// use PEAR for this! no more 'connectdb' here!!! |
* + new |
91 |
// - extend options to en-/disable caching via a) session and/or b) database |
* ------------------------------------------------------------------------- |
92 |
|
*/ |
93 |
|
|
94 |
|
/** |
95 |
|
* |
96 |
|
* Data::Driver::Proxy -- Multiple stage data fetching and caching |
97 |
|
* |
98 |
|
* |
99 |
|
* This class (Data::Driver::Proxy) provides an abstract framework |
100 |
|
* for loading/saving arbitrary data from/to data storages interfaced |
101 |
|
* by storage *proxy*-drivers. |
102 |
|
* Don't mix these up with the concrete storage *handle*-drivers |
103 |
|
* doing the lowlevel stuff (opening files, talking sql, etc.). |
104 |
|
* These proxy-drivers are "just" wrappers around them |
105 |
|
* providing a more highlevel, consistent API making |
106 |
|
* it easier for Data::Driver::Proxy to do its main work: |
107 |
|
* |
108 |
|
* Multiple stage data fetching and caching: |
109 |
|
* |
110 |
|
* DATA, ... |
111 |
|
* ... also refered to as data, should be handled as |
112 |
|
* something called data. |
113 |
|
* |
114 |
|
* STAGES |
115 |
|
* x native php4 session: serialized payload |
116 |
|
* x single rdbms table: serialized payload |
117 |
|
* x ... via custom database wrapper |
118 |
|
* x included php-file, included php-library |
119 |
|
* o object, component, package, callbacks |
120 |
|
* x ... via php PEAR DB abstraction objects |
121 |
|
* x remote objects (items): flat attribute hash |
122 |
|
* o use Data::Object::Identity |
123 |
|
* o via Data::Driver::Proxy::RPC or others |
124 |
|
* o Data::Object::Encoder: encodes/decodes values |
125 |
|
* o Data::Object::Interpolator: interpolates/resolves references |
126 |
|
* |
127 |
|
* WORK |
128 |
|
* x move data transparently around between these stages |
129 |
|
* |
130 |
|
* TOOLS |
131 |
|
* |
132 |
|
* x Overview - Packages, Handlers and Stages: |
133 |
|
* This is weird. ;-) |
134 |
|
* - A Package can be instantiated by its namespaced classname |
135 |
|
* e.g.: "mkObject('My::Package');" |
136 |
|
* - A Package can be a Handler for Data::Driver::Proxy |
137 |
|
* - A Handler implements exactly one Stage |
138 |
|
* - Data::Driver::Proxy itself embeds these Stages: |
139 |
|
* x php4-session |
140 |
|
* x rdbms-table |
141 |
|
* - An example Handler is Data::Driver::RPC::Remote |
142 |
|
* |
143 |
|
* x Handlers: |
144 |
|
* x Data::Driver::RPC::Remote |
145 |
|
* Interacts with a RPC::XML server (todo: talk SOAP!) |
146 |
|
* using PEAR::XML::RPC. |
147 |
|
* It can cache data for "disconnected mode" using the |
148 |
|
* o Data::Driver::phpHtmlLib |
149 |
|
* o Data::Driver::PEAR::DB |
150 |
|
* x Data::Driver::PEAR::Tree (via Data::Lift) |
151 |
|
* |
152 |
|
*/ |
153 |
|
|
154 |
|
/** |
155 |
|
* Todo: |
156 |
|
* x extend options to en-/disable caching via a) session and/or b) database |
157 |
|
* o make feature available via runtime setter-method to these options |
158 |
|
* o use PEAR::Cache for caching purposes!!! |
159 |
|
* o refactor database access: use PEAR for this! no more 'connectdb' here!!! |
160 |
|
* o make database connection more flexible to make possible |
161 |
|
* to have different (probably named) proxy databases (besides a "main database") |
162 |
|
* o rename this to Data::Proxy? or split into Data::Query, Data::Result and Data::Wrapper? |
163 |
|
* |
164 |
|
*/ |
165 |
|
|
166 |
|
|
167 |
class Data_Driver_Proxy { |
class Data_Driver_Proxy { |
168 |
|
|