[SQL-CVS] [ sqlobject-Bugs-1172892 ] __connection__.style broken in .6.1
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: SourceForge.net <no...@so...> - 2008-03-07 15:03:14
|
Bugs item #1172892, was opened at 2005-03-30 03:24 Message generated for change (Settings changed) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1172892&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject release (specify) >Status: Closed >Resolution: Wont Fix Priority: 5 Private: No Submitted By: Jonathan Ellis (ellisj) Assigned to: Nobody/Anonymous (nobody) Summary: __connection__.style broken in .6.1 Initial Comment: I created a Style subclass but it didn't work. So I changed all my Style's methods to raise an exception. Still showed default behavior. Then I tried assigning _style in each class -- that worked. I'd very much like to be able to set it globally, though. ---------------------------------------------------------------------- Comment By: Michael Abraham Shulman (viritrilbia) Date: 2005-08-18 05:21 Message: Logged In: YES user_id=54785 I have encountered this problem as well (trying to use long IDs) and I think I have figured out why it happens. When you create a table class, it is a subclass of SQLObject and hence an instance of MetaSQLObject. The __new__ method of MetaSQLObject sets _connection to __connection__ if it is unset, and then sets _style to _connection.style or styles.defaultStyle if it is unset. This sounds good, however... The trick is that SQLObject itself is an instance of MetaSQLObject, so when sqlobject is *loaded*, SQLObject._style gets set to styles.defaultStyle. Nothing can be done about this, since you haven't had a chance to set __connection__ yet, let alone __connection__.style. Then when you create table classes, since they are subclasses of SQLObject, they inherit its _style attribute, so MetaSQLObject.__new__ doesn't even look at _connection.style. An even easier version of the workaround below, as long as you are only using one style in your entire program, is to set SQLObject._style to your desired style. This obviates the need for an extra base class. I think it would be best if style could be set by connection, since the style used is really a property of the database in question. I'm not sure how one would accomplish this, however, if the above is indeed the problem. Maybe MetaSQLObject.__new__ should decline to set _style if it is not setting _connection as well? ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2005-03-30 18:20 Message: Logged In: NO That is a nice workaround, but either dbconnection.style should work or it should be removed... ---------------------------------------------------------------------- Comment By: Oleg Broytmann (phd) Date: 2005-03-30 16:08 Message: Logged In: YES user_id=4799 Create a class that will be served as the base class for all your tables. Assign your style to it: class Base(SQLObject): _style = MyStyle() class MyTable(Base): ... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1172892&group_id=74338 |