Hi all :)
I have a regacy db (4dbs and 8 tables, for distirube data) and wanna
build a web tool for these.
When django 1.1.x released, I sovled "4dbs" problem the multi
database.
But I have the problem yet that "8 tables"
Some months ago, I worte a code like bellow for sovling the problem
class Post(models.Model):
title = ...
created_at = ...
def _save(self):
self._select_table()
self.save()
self._restore_meta()
def _select_table(self):
key = 5 # generated by some rules
self._meta.db_table = "Post%d" % key
def _restore_meta(self):
self._meta.db_table = "Post"
class Meta:
# Post is a merge table of MySQL
db_table = 'Post'
And then, I got other problem, "self._meta.db_table" is not attribute
of object, is attribute of Post class!!!
So, aquire lock when call _select_table.
from threading import Lock
class Post(models.Model):
__lock = Lock()
...
def _save(self):
with Post.__lock:
self._select_table()
self.save()
self._restore_meta()
I think this is very poor code!!!
How to use a model with many tables? (same schema..)
Sorry for poor English :(
Any way thanks to read!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.