Re: [SQLObject] Preventing Duplicate Class Definitions
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Luke O. <lu...@me...> - 2004-10-01 18:50:25
|
I'll see if I can get a unit test together to illustrate a problem I've been
having, but here's the scenario (may be a python import issue that we can't
get around either, I recall problems with imports with different import lines,
but here the lines at least look the same...)
File structure:
./ <-- webware py/psps mostly live here, importing Objects.X
./Objects <-- primarily SQLObjects
./Objects/Core <-- a few central things here, where the problem is.
the absolute path to ./ is in PYTHONPATH.
So both a psp/py in ./ and a script in ./Objects/Core use an import line like:
from Objects.User import User
but this leads to a duplicate class error from SQLObject.
The full import pattern looks like:
./Page.py -> from Objects.User import User
./Objects.User is imported
./Page.py -> from Objects.Core.CheckUser import CheckUser
./Objects/Core/CheckUser.py -> from Objects.User import User
Note, this is on an existing app using 0.5, I'll try to get some time to track
it down further next week.
- Luke
Quoting Brad Bollenbach <br...@bb...>:
> Hi all,
>
> So I've written a little unit test to merge a small patch from Steve
> Alexander to prevent defining the same class twice. The functionality
> this adds is perhaps best described by the unit test:
>
> class ClassRegistryTest(SQLObjectTest):
> def testErrorOnDuplicateClassDefinition(self):
> """Raise an error if a class is defined more than once."""
> class Duplicate(SQLObject):
> pass
>
> try:
> class Duplicate(SQLObject):
> pass
> except ValueError, err:
> self.assertEqual(str(err), "class Duplicate is already in
> the registry")
> else:
> self.fail("should have raised an error on duplicate class
> definition")
>
> It's been quite a while since I've been involved in SQLObject
> development, but there are more patches on the way (I just have to
> write unit tests before I check them in), so I'd like to get some
> feedback from the list to ensure the time I'm spending on this and
> upcoming patches is time well spent.
>
> Comments appreciated; silence is consent. ;)
>
> Cheers,
>
> --
> Brad Bollenbach
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
> Use IT products in your business? Tell us what you think of them. Give us
> Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
> http://productguide.itmanagersjournal.com/guidepromo.tmpl
> _______________________________________________
> sqlobject-discuss mailing list
> sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
--
The Pursuit of Counterfactual Histories
|