Added DTDs, DTD

This commit is contained in:
david 2002-05-18 20:30:17 +00:00
parent 4278cf3a56
commit 03b4e828c9
2 changed files with 35 additions and 21 deletions

View File

@ -114,6 +114,7 @@ class Lampadas:
self.Config.Load()
self.Docs = Docs()
self.Docs.Load()
self.DTDs = DTDs()
self.Languages = Languages()
self.Strings = Strings()
self.Topics = Topics()
@ -143,7 +144,6 @@ class Classes(LampadasCollection):
newClass.Load(row)
self.data[newClass.ID] = newClass
class Class:
def __init__(self, ClassID=None):
@ -162,7 +162,6 @@ class Class:
newClassI18n.Load(self.row)
self.I18n[newClassI18n.Lang] = newClassI18n
class ClassI18n:
def Load(self, row):
@ -220,7 +219,6 @@ class Docs(LampadasCollection):
DB.Commit()
del self[id]
class Doc:
"""
A document in any format, whether local or remote.
@ -302,7 +300,6 @@ class DocErrors(LampadasList):
newDocError.Error = Error
self.list = self.list + [newDocError]
DB.Commit()
class DocError:
"""
@ -336,7 +333,6 @@ class DocFiles(LampadasCollection):
newDocFile.Load(DocID, row)
self.data[newDocFile.Filename] = newDocFile
class DocFile:
"""
An association between a document and a file.
@ -411,7 +407,6 @@ class DocRatings(LampadasCollection):
if not self.Parent == None:
self.Parent.Rating = self.Average
class DocRating:
"""
A rating of a document, assigned by a registered user.
@ -453,7 +448,6 @@ class DocVersions(LampadasCollection):
newDocVersion.Load(DocID, row)
self.data[newDocVersion.ID] = newDocVersion
class DocVersion:
"""
A release of the document.
@ -475,6 +469,34 @@ class DocVersion:
DB.Commit()
# DTDs
class DTDs(LampadasCollection):
"""
A collection object of all DTDs.
"""
def __init__(self):
self.data = {}
self.sql = "SELECT dtd from dtd"
self.cursor = DB.Select(self.sql)
while (1):
row = self.cursor.fetchone()
if row == None: break
newDTD = DTD()
newDTD.Load(row)
self.data[newDTD.DTD] = newDTD
class DTD:
def __init__(self, DTD=None):
if DTD==None: return
self.DTD = DTD
def Load(self, row):
self.DTD = trim(row[0])
# Languages
class Languages(LampadasCollection):
@ -493,7 +515,6 @@ class Languages(LampadasCollection):
newLanguage.Load(row)
self.data[newLanguage.Code] = newLanguage
class Language:
def __init__(self, LanguageCode=None):
@ -526,7 +547,6 @@ class Strings(LampadasCollection):
newString.Load(row)
self.data[newString.Code] = newString
class String:
def __init__(self, StringCode=None):
@ -572,7 +592,6 @@ class Topics(LampadasCollection):
newTopic.Load(row)
self.data[newTopic.Num] = newTopic
class Topic:
def __init__(self, TopicNum=None):
@ -591,7 +610,6 @@ class Topic:
newTopicI18n.Load(self.row)
self.I18n[newTopicI18n.Lang] = newTopicI18n
class TopicI18n:
def Load(self, row):
@ -679,7 +697,6 @@ class UserDocs(LampadasList):
DB.Commit()
del self.col[DocID]
class UserDoc:
"""
An association between a user and a document.
@ -707,9 +724,6 @@ class UserDoc:
self.sql = "UPDATE document_user SET role=" + wsq(self.Role) + ", email=" + wsq(self.Email) + ", active=" + wsq(bool2tf(self.Active)) + " WHERE doc_id=" + str(self.DocID) + " AND user_id=" + str(self.UserID)
DB.Exec(self.sql)
DB.Commit()
# Utility routines

View File

@ -30,7 +30,6 @@ class testConfigFIle(unittest.TestCase):
assert Config.DBType == "pgsql", "DBType is not valid"
assert Config.DBName == "lampadas", "Database name is not valid"
class testDatabase(unittest.TestCase):
def setUp(self):
@ -43,14 +42,12 @@ class testDatabase(unittest.TestCase):
self.Cursor = DB.Cursor
assert not self.Cursor == None
class testClasses(unittest.TestCase):
def testClasses(self):
assert not L.Classes == None
assert L.Classes.Count() > 0
class testConfig(unittest.TestCase):
def testConfig(self):
@ -172,7 +169,6 @@ class testDocRatings(unittest.TestCase):
assert Doc.Ratings.Count() == 0
assert Doc.Ratings.Average == 0
assert Doc.Rating == 0
class testDocVersions(unittest.TestCase):
@ -191,7 +187,12 @@ class testDocVersions(unittest.TestCase):
assert Version.PubDate > ''
assert Version.Initials > ''
assert found == 1
class testDTDs(unittest.TestCase):
def testDTDs(self):
assert L.DTDs.Count() > 0
assert not L.DTDs['DocBook'] == None
class testLanguages(unittest.TestCase):
@ -243,7 +244,6 @@ class testUsers(unittest.TestCase):
self.NewID = DB.Value('SELECT MAX(user_id) from username')
assert self.NewID == self.OldID
class testUserDocs(unittest.TestCase):
def setUp(self):