Revision: 8074
http://svn.sourceforge.net/mailman/?rev=8074&view=rev
Author: mindlace23
Date: 2006-10-19 12:51:24 -0700 (Thu, 19 Oct 2006)
Log Message:
-----------
more improvements to table schema and the object mappers
Modified Paths:
--------------
branches/soc2006-webui/Mailman/DB/object_mappers.py
branches/soc2006-webui/Mailman/DB/table_schema.py
Modified: branches/soc2006-webui/Mailman/DB/object_mappers.py
===================================================================
--- branches/soc2006-webui/Mailman/DB/object_mappers.py 2006-10-19 19:50:28 UTC
(rev 8073)
+++ branches/soc2006-webui/Mailman/DB/object_mappers.py 2006-10-19 19:51:24 UTC
(rev 8074)
@@ -8,6 +8,27 @@
db = DB()
+class ResultDict(dict):
+ """This class allows mapped results to behave like a dictionary."""
+ def append(self, item):
+ self[item.name] = item
+ def __iter__(self):
+ return self.values()
+
+class WithSettings(object):
+ """This class allows settings to be treated as attributes."""
+ settings = ResultDict
+ def __getattr__(self, item):
+ if self.settings.has_key(item):
+ return self.settings[item]
+
+ def __setattr__(self, name, value):
+ if self.__dict__.has_key(name):
+ self.__dict__[name] = value
+ else:
+ asetting = Setting(name, value)
+ self.settings.append(asetting)
+
class Access(object):
pass
mapper(Access, db.access)
@@ -17,6 +38,10 @@
mapper(EmailAddress,db.email_address)
class Setting(object):
+ def __init__(self, name, value):
+ self.name = name
+ self.value = value
+
def _set_value(self, value):
if type(value) is types.BooleanType:
self.boolean_value = value
@@ -40,15 +65,16 @@
mapper(Setting,db.setting)
-class User(object):
+class User(WithSettings):
pass
+
mapper(User, db.user_id_pass, properties= {
'email_addresses': relation(EmailAddress),
'settings': relation(Settings),
'access': relation(Access)
}
)
-class List(object):
+class List(WithSettings):
"""opaque key = KEY, lower-cased email address = LCE, case-preserved email
= CPE"""
def getMembers(self):
@@ -96,9 +122,11 @@
)
)
-class Domain(object):
- pass
-mapper(List, db.list, properties = {
+class Domain(WithSettings):
+ def __init__(self, name):
+ self.name = name
+
+mapper(Domain, db.list, properties = {
'users': relation(User),
'lists': relation(List),
'settings': relation(Setting)
Modified: branches/soc2006-webui/Mailman/DB/table_schema.py
===================================================================
--- branches/soc2006-webui/Mailman/DB/table_schema.py 2006-10-19 19:50:28 UTC
(rev 8073)
+++ branches/soc2006-webui/Mailman/DB/table_schema.py 2006-10-19 19:51:24 UTC
(rev 8074)
@@ -67,7 +67,8 @@
Column('target_user',String(36),ForeignKey('user_id_pass.uuid') ),
Column('target_list',String(36),ForeignKey('list.uuid') ),
Column('target_domain',String(36),ForeignKey('domain.uuid') ),
- Column('type',Integer,ForeignKey('setting_type.id') ),
Column('boolean_value',Boolean),
+ Column('type',Integer,ForeignKey('setting_type.id') ),
+ Column('boolean_value',Boolean),
Column('integer_value',Integer),
Column('float_value',Float),
Column('text_value',TEXT),
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org