~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/datasources/drivers/special/unbound/Driver.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This file is part of GNU Enterprise.
 
3
#
 
4
# GNU Enterprise is free software; you can redistribute it 
 
5
# and/or modify it under the terms of the GNU General Public 
 
6
# License as published by the Free Software Foundation; either 
 
7
# version 2, or (at your option) any later version.
 
8
#
 
9
# GNU Enterprise is distributed in the hope that it will be 
 
10
# useful, but WITHOUT ANY WARRANTY; without even the implied 
 
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
12
# PURPOSE. See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public 
 
15
# License along with program; see the file COPYING. If not, 
 
16
# write to the Free Software Foundation, Inc., 59 Temple Place 
 
17
# - Suite 330, Boston, MA 02111-1307, USA.
 
18
#
 
19
# Copyright 2001-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# _empty/DBdriver.py
 
23
#
 
24
# DESCRIPTION:
 
25
# Virtual database driver for a dataless/connectionless client
 
26
#
 
27
# NOTES:
 
28
# Primarily used by unbound forms blocks
 
29
#
 
30
 
 
31
import string
 
32
from gnue.common.datasources.drivers.Base import *
 
33
 
 
34
 
 
35
###########################################################
 
36
#
 
37
# This is an empty data driver for connectionless clients
 
38
# (primarily used by forms)
 
39
 
40
###########################################################
 
41
class NIL_DataObject (DataObject): 
 
42
 
 
43
  def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None, sql=""): 
 
44
    return NIL_ResultSet(self, masterRecordSet=masterRecordSet)
 
45
 
 
46
  # We don't do logins
 
47
  def getLoginFields(self):
 
48
    return ()
 
49
 
 
50
  # We don't do connections (we are connectionless)
 
51
  def connect(self, connectData={}):
 
52
    self._postConnect()
 
53
 
 
54
  # We don't do commits
 
55
  def commit(self):
 
56
    pass
 
57
 
 
58
  # And we don't do rollbacks
 
59
  def rollback(self):
 
60
    pass
 
61
 
 
62
 
 
63
 
 
64
###########################################################
 
65
#
 
66
 
67
 
68
###########################################################
 
69
class NIL_ResultSet(ResultSet): 
 
70
 
 
71
  def __init__(self, dataObject, cursor=None, defaultValues={}, masterRecordSet=None): 
 
72
    ResultSet.__init__(self, dataObject, \
 
73
            cursor, defaultValues, masterRecordSet)
 
74
    self._recordSetClass = NIL_RecordSet
 
75
 
 
76
 
 
77
  # Returns 1=DataObject has uncommitted changes 
 
78
  def isPending(self):
 
79
    return 0    # Empty DataObjects cannot have pending changes :)
 
80
 
 
81
  # Post changes to the database
 
82
  def post(self):
 
83
    # Leave this here in case (for some bizarro reason)
 
84
    # a bound dataobject uses us as a master
 
85
    for record in (self._cachedRecords): 
 
86
      record.post()
 
87
 
 
88
  # Returns 1=Field is bound to a database field
 
89
  def isFieldBound(self, fieldName):
 
90
    return 0
 
91
 
 
92
  # Load cacheCount number of new records
 
93
  def _loadNextRecord(self): 
 
94
    return 0
 
95
 
 
96
 
 
97
  # Create an empty record
 
98
  def _createEmptyRecord(self): 
 
99
    return self._recordSetClass(self)
 
100
 
 
101
 
 
102
###########################################################
 
103
 
104
#
 
105
 
106
###########################################################
 
107
class NIL_RecordSet (RecordSet): 
 
108
 
 
109
  def isPending(self):
 
110
    return 0
 
111
 
 
112
  # Post any changes to database
 
113
  def _postChanges(self, recordNumber=None): 
 
114
    return 1
 
115
 
 
116
 
 
117
 
 
118
#
 
119
#  Extensions to Trigger Namespaces
 
120
#  
 
121
class TriggerExtensions: 
 
122
  def __init__(self, connection): 
 
123
    self.__connection = connection
 
124
 
 
125
 
 
126
 
 
127
######################################
 
128
#
 
129
#  The following hashes describe 
 
130
#  this driver's characteristings.
 
131
#
 
132
######################################
 
133
 
 
134
#
 
135
#  All datasouce "types" and corresponding DataObject class
 
136
 
137
supportedDataObjects = { 
 
138
  'object': NIL_DataObject
 
139
}
 
140
 
 
141