importing modules

1 view
Skip to first unread message

Felix Schwarz

unread,
Nov 30, 2007, 6:27:42 AM11/30/07
to apy...@googlegroups.com

Looks nice. Unfortunately, I was not able to generate some api docs for
my TurboGears-based application because apydia tries to import every
module before generating the documentation - for certain modules (model)
TurboGears tries to find the database configuration (connection
parameters etc) at import time which is missing when apydia runs because
the app was not started. And 90% of my modules require one of the model
files...

Is there any known workaround for this?

fs

Daniel Haus

unread,
Nov 30, 2007, 6:35:32 AM11/30/07
to Apydia
Felix Schwarz schrieb:
Unfortunately not yet. In fact, I hadn't an idea that this problem
exists. Thank you for the report, I'll have to see how to fix this.

Daniel Haus

unread,
Dec 1, 2007, 3:51:17 AM12/1/07
to Apydia
Looks like it'd be much cleaner to avoid using the inspect-module.
Investigating imported modules is easy and works for many cases. But
it's not the robust approach that would perfectly work with *any*
(syntactically correct) code. Maybe I can step a few levels lower, if
that's somehow possible.

A workaround would be far from trivial. I need to dig deeper into
python's wealth of possibilites...

Daniel Haus

unread,
Dec 1, 2007, 6:43:44 AM12/1/07
to Apydia
And yet another reply, but this time it's good news. As most of the
time the solution was much easier than I expected it to be. I added a
couple of exception handlers and now it works. At least for an older
TurboGears-project of mine, and for TurboGears itself (the docstrings
could be better, but let's not start this again).

Please try the latest revision from trunk (http://apydia.ematia.de/svn/
apydia/trunk/ ) and tell me if it works for you.

Greetings

--
Daniel Haus
http://ematia.de

Felix Schwarz

unread,
Dec 4, 2007, 1:13:46 PM12/4/07
to apy...@googlegroups.com
Daniel Haus schrieb:

> Please try the latest revision from trunk (http://apydia.ematia.de/svn/
> apydia/trunk/ ) and tell me if it works for you.

Much better now but I still have a problem (see the attached traceback). apydia
seems to instantiate my classes/call some methods which does not work because
some parameters are missing. Does the traceback help you do you need a more
specific testcase?

fs

apydia.txt

Daniel Haus

unread,
Dec 5, 2007, 6:40:31 AM12/5/07
to apy...@googlegroups.com
I generalized the corresponding exception handler. Could you please
try again, if the current trunk works better for you?

> /usr/lib/python2.4/site-packages/sqlobject/main.py:589:
> DeprecationWarning: Use of this attribute should be replaced
> with .sqlmeta.addColumn
> '.sqlmeta.%s' % self.name, level=self.deprecation_level)
> /usr/lib/python2.4/site-packages/sqlobject/main.py:589:
> DeprecationWarning: Use of this attribute should be replaced
> with .sqlmeta.addIndex
> '.sqlmeta.%s' % self.name, level=self.deprecation_level)
> /usr/lib/python2.4/site-packages/sqlobject/main.py:589:
> DeprecationWarning: Use of this attribute should be replaced
> with .sqlmeta.addJoin
> '.sqlmeta.%s' % self.name, level=self.deprecation_level)
> /usr/lib/python2.4/site-packages/sqlobject/main.py:589:
> DeprecationWarning: Use of this attribute should be replaced
> with .sqlmeta.delColumn
> '.sqlmeta.%s' % self.name, level=self.deprecation_level)
> /usr/lib/python2.4/site-packages/sqlobject/main.py:589:
> DeprecationWarning: Use of this attribute should be replaced
> with .sqlmeta.delJoin
> '.sqlmeta.%s' % self.name, level=self.deprecation_level)
> /home/fs/lokal/python-modules/TurboGears-1.0.4b2dev_r3672-py2.4.egg/
> turbogears/identity/soprovider.py:44: DeprecationWarning:
> displayName has been deprecated in favour of display_name
> (self.old_name, self.new_name), DeprecationWarning )
> /home/fs/lokal/python-modules/TurboGears-1.0.4b2dev_r3672-py2.4.egg/
> turbogears/identity/soprovider.py:44: DeprecationWarning: groupId
> has been deprecated in favour of group_name
> (self.old_name, self.new_name), DeprecationWarning )
> /home/fs/lokal/python-modules/TurboGears-1.0.4b2dev_r3672-py2.4.egg/
> turbogears/identity/soprovider.py:44: DeprecationWarning:
> permissionId has been deprecated in favour of permission_name
> (self.old_name, self.new_name), DeprecationWarning )
> /home/fs/lokal/python-modules/TurboGears-1.0.4b2dev_r3672-py2.4.egg/
> turbogears/identity/soprovider.py:44: DeprecationWarning:
> emailAddress has been deprecated in favour of email_address
> (self.old_name, self.new_name), DeprecationWarning )
> /home/fs/lokal/python-modules/TurboGears-1.0.4b2dev_r3672-py2.4.egg/
> turbogears/identity/soprovider.py:44: DeprecationWarning: userId has
> been deprecated in favour of user_name
> (self.old_name, self.new_name), DeprecationWarning )
> Traceback (most recent call last):
> File "/home/fs/lokal/python-modules/apydia", line 7, in ?
> sys.exit(
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/command.py", line 254, in main
> project = Project(options)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/project.py", line 65, in __init__
> desc = create_desc(sys.modules[module_name])
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 366, in create_desc
> return class_(value)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 188, in __init__
> for name, desc in self.find_submodules():
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 245, in find_submodules
> m = ModuleDesc.load(name)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 204, in load
> return create_desc(sys.modules[pathname])
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 366, in create_desc
> return class_(value)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 188, in __init__
> for name, desc in self.find_submodules():
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 245, in find_submodules
> m = ModuleDesc.load(name)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 204, in load
> return create_desc(sys.modules[pathname])
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 366, in create_desc
> return class_(value)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 184, in __init__
> super(ModuleDesc, self).__init__(module)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 78, in __init__
> self._members = self.find_members()
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 231, in find_members
> desc = create_desc(value)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 366, in create_desc
> return class_(value)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 269, in __init__
> super(ClassDesc, self).__init__(class_)
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 78, in __init__
> self._members = self.find_members()
> File "/home/fs/lokal/python-modules/Apydia-0.0.2.dev_r24-py2.4.egg/
> apydia/descriptors.py", line 289, in find_members
> desc = create_desc(getattr(self.value, key))
> File "/usr/lib/python2.4/site-packages/formencode/declarative.py",
> line 105, in __get__
> obj = type.singleton()
> File "/usr/lib/python2.4/site-packages/formencode/declarative.py",
> line 166, in singleton
> setattr(cls, name, cls(declarative_count=cls.declarative_count))
> File "/usr/lib/python2.4/site-packages/formencode/api.py", line
> 165, in __init__
> declarative.Declarative.__init__(self, *args, **kw)
> File "/usr/lib/python2.4/site-packages/formencode/declarative.py",
> line 153, in __init__
> self.__initargs__(kw)
> File "/home/fs/workspace/foo/src/foo/controllers/validation/
> order_validation.py", line 258, in __initargs__
> self.condition = args["condition"]
> KeyError: 'condition'

Felix Schwarz

unread,
Dec 5, 2007, 8:29:59 AM12/5/07
to apy...@googlegroups.com
Daniel Haus schrieb:

> I generalized the corresponding exception handler. Could you please
> try again, if the current trunk works better for you?

Unfortunately, the problem is still present in r24.

fs

Daniel Haus

unread,
Dec 5, 2007, 8:31:16 AM12/5/07
to apy...@googlegroups.com

Please try r27.

Felix Schwarz

unread,
Dec 5, 2007, 10:00:47 AM12/5/07
to apy...@googlegroups.com
Daniel Haus schrieb:

> Am 05.12.2007 um 14:29 schrieb Felix Schwarz:
>
>> Daniel Haus schrieb:
>>> I generalized the corresponding exception handler. Could you please
>>> try again, if the current trunk works better for you?
>> Unfortunately, the problem is still present in r24.
>
> Please try r27.

Much better now - thank you :-)

fs

Reply all
Reply to author
Forward
0 new messages