Pгoмᴇтнᴇυs 0x01 | 10 May 2011 21:08
Picon

Registry error? (class X is already in the registry)

Hi all,

First, thanks for the help and support with all my earlier queries (especially Oleg); you've all helped me a lot with this stuff, and I've gotten over all my previous problems.

I currently have a new problem (I am using a wrapper to run python scripts like a PHP script/cgi script):

Traceback (most recent call last):
  File "/local/lf/index.py", line 38, in main
    oContent = Content(sPageName, req);
  File "/local/lf/content.py", line 75, in __init__
    self.template, self.module = self.loadTemplate(self.view.template);
  File "/local/lf/content.py", line 277, in loadTemplate
    __import__(config.sModulePrefix + sTemplateModule);
  File "/local/lf/lf/__init__.py", line 62, in
    import db;
  File "/local/lf/db.py", line 34, in
    class View(SQLObject):
  File "/usr/local/lib/python2.6/dist-packages/SQLObject-1.0.0-py2.6.egg/sqlobject/declarative.py", line 92, in __new__
    cls.__classinit__(cls, new_attrs)
  File "/usr/local/lib/python2.6/dist-packages/SQLObject-1.0.0-py2.6.egg/sqlobject/main.py", line 818, in __classinit__
    classregistry.registry(sqlmeta.registry).addClass(cls)
  File "/usr/local/lib/python2.6/dist-packages/SQLObject-1.0.0-py2.6.egg/sqlobject/classregistry.py", line 91, in addClass
    '__file__', '(unknown)')))
ValueError: class View is already in the registry (other class is , from the module lf.db in /local/lf/db.pyc; attempted new class

Any ideas on what I can do to overcome this? I've tried to replicate this error in python (interactive mode), but I haven't been able to. What causes this error exactly?

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Sean DiZazzo | 10 May 2011 21:54
Picon

Re: Registry error? (class X is already in the registry)

Im just guessing here, but perhaps you should try naming your class something other than "View"

On Tue, May 10, 2011 at 12:08 PM, Pгoмᴇтнᴇυs 0x01 <prometheus.0x01 <at> gmail.com> wrote:
Hi all,

First, thanks for the help and support with all my earlier queries (especially Oleg); you've all helped me a lot with this stuff, and I've gotten over all my previous problems.

I currently have a new problem (I am using a wrapper to run python scripts like a PHP script/cgi script):

Traceback (most recent call last):
  File "/local/lf/index.py", line 38, in main
    oContent = Content(sPageName, req);
  File "/local/lf/content.py", line 75, in __init__
    self.template, self.module = self.loadTemplate(self.view.template);
  File "/local/lf/content.py", line 277, in loadTemplate
    __import__(config.sModulePrefix + sTemplateModule);
  File "/local/lf/lf/__init__.py", line 62, in
    import db;
  File "/local/lf/db.py", line 34, in
    class View(SQLObject):
  File "/usr/local/lib/python2.6/dist-packages/SQLObject-1.0.0-py2.6.egg/sqlobject/declarative.py", line 92, in __new__
    cls.__classinit__(cls, new_attrs)
  File "/usr/local/lib/python2.6/dist-packages/SQLObject-1.0.0-py2.6.egg/sqlobject/main.py", line 818, in __classinit__
    classregistry.registry(sqlmeta.registry).addClass(cls)
  File "/usr/local/lib/python2.6/dist-packages/SQLObject-1.0.0-py2.6.egg/sqlobject/classregistry.py", line 91, in addClass
    '__file__', '(unknown)')))
ValueError: class View is already in the registry (other class is , from the module lf.db in /local/lf/db.pyc; attempted new class

Any ideas on what I can do to overcome this? I've tried to replicate this error in python (interactive mode), but I haven't been able to. What causes this error exactly?


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 10 May 2011 21:57
X-Face
Favicon
Gravatar

Re: Registry error? (class X is already in the registry)

On Tue, May 10, 2011 at 01:08:46PM -0600, Pгoм???тн?????s 0x01 wrote:
> ValueError: class View is already in the registry (other class is , from the
> module lf.db in /local/lf/db.pyc; attempted new class

   Are you sure you don't have two classes named View? If not I suspect
somewhere (may be in PHP-Python bridge) there are sys.path manipulations
and you ended up importing the same module twice as different modules.
Try to print sys.modules.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Pгoмᴇтнᴇυs 0x01 | 10 May 2011 22:18
Picon

Re: Registry error? (class X is already in the registry)

Is it possible for it to be loading the same class twice? (I am using raw__import__ statements) -- and if so, is there any way to use some kind of if/else statement to avoid a dual attempt?

The big picture is that I have a uWSGI application "loader.py" which then loads up the requested *.py file and calls a run function within that file.

So index.py has that run function, and it loads up a View object from SQLObject and from there  determines what other additional modules to load, etc...

2011/5/10 Oleg Broytman <phd <at> phdru.name>
On Tue, May 10, 2011 at 01:08:46PM -0600, Pгoм???тн?????s 0x01 wrote:
> ValueError: class View is already in the registry (other class is , from the
> module lf.db in /local/lf/db.pyc; attempted new class

  Are you sure you don't have two classes named View? If not I suspect
somewhere (may be in PHP-Python bridge) there are sys.path manipulations
and you ended up importing the same module twice as different modules.
Try to print sys.modules.

Oleg.
--
    Oleg Broytman            http://phdru.name/            phd <at> phdru.name
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 10 May 2011 23:04
X-Face
Favicon
Gravatar

Re: Registry error? (class X is already in the registry)

On Tue, May 10, 2011 at 02:18:55PM -0600, Pгoм???тн?????s 0x01 wrote:
> Is it possible for it to be loading the same class twice?

   Yes, and bugs caused by dual import are, in my opinion, the most
painful to debug.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Pгoмᴇтнᴇυs 0x01 | 10 May 2011 23:33
Picon

Re: Registry error? (class X is already in the registry)

Is there something I can do to catch this? Should I be using some kind of registry or dictionary to keep track of imports? (Would that help?)

2011/5/10 Oleg Broytman <phd <at> phdru.name>
On Tue, May 10, 2011 at 02:18:55PM -0600, Pгoм???тн?????s 0x01 wrote:
> Is it possible for it to be loading the same class twice?

  Yes, and bugs caused by dual import are, in my opinion, the most
painful to debug.

Oleg.
--
    Oleg Broytman            http://phdru.name/            phd <at> phdru.name
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 10 May 2011 23:50
X-Face
Favicon
Gravatar

Re: Registry error? (class X is already in the registry)

On Tue, May 10, 2011 at 03:33:43PM -0600, Pгoм???тн?????s 0x01 wrote:
> Is there something I can do to catch this? Should I be using some kind of
> registry or dictionary to keep track of imports? (Would that help?)

   In my experience, problematic import is usually a result of mixed
absolute and relative import - a submodule A imports submodule X as
parent.X and submodule B imports X as X; add sys.path manipulations and
voila - X is imported both as parent.X and top-level X.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Pгoмᴇтнᴇυs 0x01 | 11 May 2011 21:10
Picon

Re: Registry error? (class X is already in the registry)

Thanks; I'm gonna have to comb through that code later and try to figure out how to avoid this.

2011/5/10 Oleg Broytman <phd <at> phdru.name>
On Tue, May 10, 2011 at 03:33:43PM -0600, Pгoм???тн?????s 0x01 wrote:
> Is there something I can do to catch this? Should I be using some kind of
> registry or dictionary to keep track of imports? (Would that help?)

  In my experience, problematic import is usually a result of mixed
absolute and relative import - a submodule A imports submodule X as
parent.X and submodule B imports X as X; add sys.path manipulations and
voila - X is imported both as parent.X and top-level X.

Oleg.
--
    Oleg Broytman            http://phdru.name/            phd <at> phdru.name
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Pгoмᴇтнᴇυs 0x01 | 11 May 2011 21:14
Picon

Custom query results?

Hi all,

I was wondering if it was possible to attach columns from another table (a many-to-many relationship table) to results returned from er-- that other table.

To use an example from the SQLObject documentation:
http://sqlobject.org/FAQ.html#how-can-i-define-my-own-intermediate-table-in-my-many-to-many-relationship

Is it possible to have User.roles return the Role information along with 'active' from the UserRoles class? How might this be done?

Thanks again!

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
Oleg Broytman | 11 May 2011 21:52
X-Face
Favicon
Gravatar

Re: Custom query results?

On Wed, May 11, 2011 at 01:14:22PM -0600, Pгoм???тн?????s 0x01 wrote:
> I was wondering if it was possible to attach columns from another table

   Not with high-level API (classes/instances); see

http://sqlobject.org/FAQ.html#how-can-i-do-a-left-join

   See also sqlbuilder.Select:

http://sqlobject.org/SQLBuilder.html#select

   but it's lower-level API.

Oleg.
--

-- 
     Oleg Broytman            http://phdru.name/            phd <at> phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Gmane