Opened 12 years ago
Closed 12 years ago
#19068 closed Bug (duplicate)
comments in a multiple database context
Reported by: | Eric Simorre | Owned by: | nobody |
---|---|---|---|
Component: | contrib.comments | Version: | |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
a legacy database, another database to store (django.contrib.admin.)comments: it does not work.
Change History (8)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
I wouldn't be surprised if contrib.comments had issues related to multiple databases. But neither of the changes suggested would improve multiple database support. _default_manager, for example, is usually the same as .objects, unless a new default manager is being used (in which case that should probably be used instead of .objects).
It would be great if you could gather more information and reopen this ticket. What's the exact problem you're seeing? Are you getting any kind of traceback?
comment:3 by , 12 years ago
my contenttypes' table is in sqlitedb , self.model_class() is stored in oracledb
this expression is incorrect because "self" is a ContentType object
self.model_class()._base_manager.using(self._state.db).get(**kwargs)
The commented object (oracledb) is searched in the contenttype sqlitedb. If "objects" is used, the db is right.
I have no trace (the project is deployed in an intranet), but the error message is: table xxx not found.
comment:4 by , 12 years ago
Resolution: | needsinfo |
---|---|
Status: | closed → reopened |
comment:5 by , 12 years ago
It is obvious that the line code below raise a "table xxx not found" exception if ContentType and the target model are stored in 2 distincts db
class ContentType: ... return self.model_class()._base_manager.using(self._state.db).get(**kwargs)
Same thing below if the Comment model and the target model are stored in 2 distincts db
class CommentDetailsForm: ... possible_duplicates = self.get_comment_model()._default_manager.using( self.target_object._state.db )....
By using the default manager "objects", the bug is fixed. I confirm that it works.
It's very interesting, you can comment objects stored in a legacy database without storing extra data inside.
comment:7 by , 12 years ago
not exactly because the target component is contrib.comment; but both should be analysed together.
comment:8 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
I would suggest to replace _base_manager.using(self._state.db) by objects below
idem for _default_manager.using(self.target_object._state.db) below