So, I have some code that is constructing a declarative table definition on 
the fly, built from a YAML file. It works great. However, when I try to do 
*help(tablename)*, I get the following error:

Python 3.4.3 (default, May 14 2015, 09:48:44)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pampas.sql import tables
>>> tables.pampas.Plugin
<class 'pampas.sql.tables.pampas.Plugin'>
>>> help(tables.pampas.Plugin)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/_sitebuiltins.py", line 103, in 
__call__
    return pydoc.help(*args, **kwds)
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 1827, in __call__
    self.help(request)
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 1877, in help
    else: doc(request, 'Help on %s:', output=self._output)
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 1614, in doc
    pager(render_doc(thing, title, forceload))
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 1607, in 
render_doc
    return title % desc + '\n\n' + renderer.document(object, name)
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 372, in document
    if inspect.isclass(object): return self.docclass(*args)
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 1272, in docclass
    for name, kind, cls, value in classify_class_attrs(object)
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/pydoc.py", line 205, in 
classify_class_attrs
    for (name, kind, cls, value) in inspect.classify_class_attrs(object):
  File "/lfs/opt/qqpamp0/pkg/lib/python3.4/inspect.py", line 405, in 
classify_class_attrs
    obj = get_obj or dict_obj
  File 
"/lfs/opt/qqpamp0/venv/cliff/lib/python3.4/site-packages/sqlalchemy/sql/elements.py",
 
line 539, in __bool__
    raise TypeError("Boolean value of this clause is not defined")
TypeError: Boolean value of this clause is not defined


Mind you, this only happens if I try to do help() on my table. It doesn't 
come up otherwise. I have warned people using my API in my company away 
from using help(), and instead relying on the table definition in the 
database and/or the YAML files.

Essentially, what is done is:

   1. Code looks up a YAML definition locally for the table.
   2. if the file doesn't exist, it uses DB reflection to construct the 
   file.
   3. Load the YAML file
   4. Use the YAML file to construct the required namespace dict to pass to 
   sqlalchemy.ext.declarative.api.DeclarativeMeta(), using my existing 
   declarative_base instance for the base class of my new class.
   5. Returns the class definition constructed 
   from sqlalchemy.ext.declarative.api.DeclarativeMeta(). (note, I have used 
   type() rather than sqlalchemy.ext.declarative.api.DeclarativeMeta() with 
   the same results).

This all works well, and I am very happy it does. However, where it is 
lacking is that help() is broken. When I make a table statically, I have no 
such problem. When I am attempting to construct it dynamically, I run into 
this problem.

I have considered constructing the class definition completely as a string, 
and then exec() the whole thing, as this could work for me. However I'd 
hope there was a solution that wouldn't involve such a heavy-handed 
alteration to my code.

I am running SQLAlchemy 1.0.8, on Python 3.4.3.

Thanks for any help.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to