[Zope-CVS] CVS: Products/Ape/lib/apelib/sql -
classification.py:1.5.4.2 oidgen.py:1.1.2.3
properties.py:1.5.2.2 querygen.py:1.4.2.1 security.py:1.4.6.2
sqlbase.py:1.9.2.2 structure.py:1.5.6.3
Shane Hathaway
shane at zope.com
Tue Dec 23 00:53:07 EST 2003
Update of /cvs-repository/Products/Ape/lib/apelib/sql
In directory cvs.zope.org:/tmp/cvs-serv30737/lib/apelib/sql
Modified Files:
Tag: ape-0_8-branch
classification.py oidgen.py properties.py querygen.py
security.py sqlbase.py structure.py
Log Message:
The PostgreSQL tests now pass.
Some minor changes to interfaces were necessary in order to
find and call all database initializers.
=== Products/Ape/lib/apelib/sql/classification.py 1.5.4.1 => 1.5.4.2 ===
--- Products/Ape/lib/apelib/sql/classification.py:1.5.4.1 Sat Dec 20 02:31:05 2003
+++ Products/Ape/lib/apelib/sql/classification.py Tue Dec 23 00:52:36 2003
@@ -17,6 +17,7 @@
"""
from apelib.core.schemas import FieldSchema
+from apelib.core.interfaces import ConflictError
from sqlbase import SQLGatewayBase
@@ -26,7 +27,7 @@
schema = FieldSchema('classification', 'classification')
- table_base_name = 'classification2' # Version 2
+ table_base_name = 'classification'
column_defs = (
('class_name', 'string', 0),
@@ -48,9 +49,12 @@
def store(self, event, classification):
items = self.execute(event, 'read', 1, oid=event.oid)
+ if items and event.is_new:
+ # Something is already stored at this OID.
+ raise ConflictError(event.oid)
cn = classification.get('class_name', '')
mn = classification.get('mapper_name', '')
- kw = {'key': key, 'class_name': cn, 'mapper_name': mn}
+ kw = {'oid': event.oid, 'class_name': cn, 'mapper_name': mn}
if items:
self.execute(event, 'update', **kw)
else:
=== Products/Ape/lib/apelib/sql/oidgen.py 1.1.2.2 => 1.1.2.3 ===
--- Products/Ape/lib/apelib/sql/oidgen.py:1.1.2.2 Sat Dec 20 23:24:05 2003
+++ Products/Ape/lib/apelib/sql/oidgen.py Tue Dec 23 00:52:36 2003
@@ -44,7 +44,7 @@
first_time = 1
if first_time:
self.execute(event, 'sequence_insert')
- if event.clearing():
+ if event.clear_all:
self.execute(event, 'sequence_clear')
conn.db.commit()
=== Products/Ape/lib/apelib/sql/properties.py 1.5.2.1 => 1.5.2.2 ===
--- Products/Ape/lib/apelib/sql/properties.py:1.5.2.1 Sat Dec 20 02:31:05 2003
+++ Products/Ape/lib/apelib/sql/properties.py Tue Dec 23 00:52:36 2003
@@ -41,40 +41,38 @@
)
def load(self, event):
- key = long(event.getKey())
- items = self.execute(event, 'read', 1, key=key)
+ items = self.execute(event, 'read', 1, oid=event.oid)
items.sort()
return items, tuple(items)
def store(self, event, state):
- key = long(event.getKey())
- items = self.execute(event, 'read', 1, key=key)
+ items = self.execute(event, 'read', 1, oid=event.oid)
state_dict = {}
for row in state:
id = row[0]
state_dict[id] = row
items_dict = {}
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
for old_row in items:
id = old_row[0]
items_dict[id] = old_row
state_row = state_dict.get(id)
if state_row is None:
# Remove a property
- self.execute(event, 'delete', key=key, id=id)
+ self.execute(event, 'delete', oid=event.oid, id=id)
elif old_row != state_row:
# Update a property
id, t, v = state_row
data = conn.asBinary(v)
self.execute(event, 'update',
- key=key, id=id, type=t, data=data)
+ oid=event.oid, id=id, type=t, data=data)
for row in state:
if not items_dict.has_key(row[0]):
# Add a property
id, t, v = row
data = conn.asBinary(v)
self.execute(event, 'insert',
- key=key, id=id, type=t, data=data)
+ oid=event.oid, id=id, type=t, data=data)
state = list(state)
state.sort()
return tuple(state)
@@ -103,7 +101,7 @@
"""Creates the fixed property table without triggering an error.
"""
# Note: event is any kind of IGatewayEvent.
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
if conn.prefix:
full_table_name = '%s_%s' % (conn.prefix, self.table_base_name)
else:
@@ -124,8 +122,7 @@
def load(self, event):
- key = long(event.getKey())
- recs = self.execute(event, 'read', fetch=1, key=key)
+ recs = self.execute(event, 'read', fetch=1, oid=event.oid)
if not recs:
return (), ()
if len(recs) > 1:
@@ -172,12 +169,11 @@
raise ValueError(
"Extra properties provided for fixed schema: %s"
% statedict.keys())
- key = event.getKey()
- recs = self.execute(event, 'read', fetch=1, key=key)
+ recs = self.execute(event, 'read', fetch=1, oid=event.oid)
if not recs:
- self.execute(event, 'insert', key=key, _data=data)
+ self.execute(event, 'insert', oid=event.oid, _data=data)
else:
- self.execute(event, 'update', key=key, _data=data)
+ self.execute(event, 'update', oid=event.oid, _data=data)
return tuple(record)
@@ -201,10 +197,10 @@
def init(self, event):
self.var_props.init(event)
- if event.clearing():
+ if event.clear_all:
# Clear the fixed property tables by searching for tables
# with a special name.
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
if conn.prefix:
to_find = '%s_fp_' % conn.prefix
else:
@@ -234,8 +230,8 @@
return None
for p in props:
prop_name = p['id']
- if prop_name == 'key':
- name = '_key'
+ if prop_name == 'oid':
+ name = '_oid'
else:
name = prop_name
cols.append((name, p['type'], 0))
=== Products/Ape/lib/apelib/sql/querygen.py 1.4 => 1.4.2.1 ===
--- Products/Ape/lib/apelib/sql/querygen.py:1.4 Mon Aug 11 13:56:05 2003
+++ Products/Ape/lib/apelib/sql/querygen.py Tue Dec 23 00:52:36 2003
@@ -36,12 +36,12 @@
column_type_translations = None # { local type name -> db type name }
column_name_translations = None # { local col name -> db col name }
- key_column = ('key', 'int', 1)
+ oid_column = ('oid', 'int', 1)
def __init__(self, table_name, column_defs):
# column_defs is a sequence of (column_name, column_type, unique)
self.table_name = table_name
- self.column_defs = (self.key_column,) + tuple(column_defs)
+ self.column_defs = (self.oid_column,) + tuple(column_defs)
def translateName(self, column_name):
"""Returns a column name for a variable name.
@@ -64,7 +64,7 @@
def gen_check(self):
- kc = self.translateName(self.key_column[0])
+ kc = self.translateName(self.oid_column[0])
# This is meant to raise an error if the table is missing.
# Returns nothing if the table exists.
return 'SELECT %s FROM %s WHERE 0 = 1' % (kc, self.table_name)
@@ -84,10 +84,10 @@
for name, typ, u in self.column_defs[1:]:
trans_name = self.translateName(name)
cols.append(trans_name)
- key_column_name = self.key_column[0]
- trans_kc = self.translateName(key_column_name)
+ oid_column_name = self.oid_column[0]
+ trans_kc = self.translateName(oid_column_name)
return 'SELECT %s FROM %s WHERE %s = %%(%s)s' % (
- ', '.join(cols), self.table_name, trans_kc, key_column_name)
+ ', '.join(cols), self.table_name, trans_kc, oid_column_name)
def gen_simple_search(self):
@@ -157,7 +157,9 @@
'date_international': 'date',
}
- column_name_translations = {}
+ column_name_translations = {
+ 'oid': 'objoid',
+ }
def gen_table_names(self):
# Returns the names of the tables.
@@ -195,7 +197,7 @@
}
column_name_translations = {
- 'key': 'objkey',
+ 'oid': 'objoid',
}
def gen_table_names(self):
=== Products/Ape/lib/apelib/sql/security.py 1.4.6.1 => 1.4.6.2 ===
--- Products/Ape/lib/apelib/sql/security.py:1.4.6.1 Sat Dec 20 02:31:05 2003
+++ Products/Ape/lib/apelib/sql/security.py Tue Dec 23 00:52:36 2003
@@ -75,9 +75,9 @@
def init(self, event):
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
try:
- if event.clearing():
+ if event.clear_all:
self.execute(event, 'users', 'clear')
self.execute(event, 'user_roles', 'clear')
self.execute(event, 'user_domains', 'clear')
@@ -92,7 +92,7 @@
def execute(self, event, table, operation, *args, **kw):
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
query = conn.getQuery(
table, self.table_defs[table], operation)
if query == '':
=== Products/Ape/lib/apelib/sql/sqlbase.py 1.9.2.1 => 1.9.2.2 ===
--- Products/Ape/lib/apelib/sql/sqlbase.py:1.9.2.1 Sat Dec 20 02:31:05 2003
+++ Products/Ape/lib/apelib/sql/sqlbase.py Tue Dec 23 00:52:36 2003
@@ -35,10 +35,10 @@
self.column_defs = tuple(self.schema.getColumnDefs())
def init(self, event):
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
assert ISQLConnection.isImplementedBy(conn)
try:
- if event.clearing():
+ if event.clear_all:
self.execute(event, 'clear')
else:
self.execute(event, 'check')
=== Products/Ape/lib/apelib/sql/structure.py 1.5.6.2 => 1.5.6.3 ===
--- Products/Ape/lib/apelib/sql/structure.py:1.5.6.2 Sat Dec 20 23:24:05 2003
+++ Products/Ape/lib/apelib/sql/structure.py Tue Dec 23 00:52:36 2003
@@ -44,7 +44,7 @@
def store(self, event, state):
items = self.execute(event, 'read', 1, oid=event.oid)
col_name = self.column_defs[0][0]
- conn = event.getConnection(self.conn_name)
+ conn = event.connections[self.conn_name]
kw = {'oid': event.oid, col_name: conn.asBinary(state)}
if items:
# update.
@@ -74,7 +74,7 @@
def load(self, event):
rows = self.execute(event, 'read', 1, oid=event.oid)
rows.sort()
- res = [(row[0], long(row[1])) for row in rows]
+ res = [(row[0], str(row[1])) for row in rows]
return res, tuple(res)
def store(self, event, state):
More information about the Zope-CVS
mailing list