[PyQt] question about dip models and dip io

Darren Dale dsdale24 at gmail.com
Wed Aug 4 22:57:12 BST 2010

At the lab where I work, we generate ascii data files that contain an
hierarchy of data. The hierarchy and the contents of the table can
vary. I am trying to understand if it is possible to use dip to
provide an interface to such data. I was thinking that each node in
the hierarchy might be accessed via a dip Model, but I need to
construct the Model based on the contents of the data file. I wondered
how well this might integrate with dip's design, so I made a slight
change to one of the tests in the dip test suite to experiment with
dynamically specifying the attributes of a model:

diff -r ae63e1237a24 test/tests/dip_io/test_xml.py
--- a/test/tests/dip_io/test_xml.py	Mon Jul 26 09:20:08 2010 -0400
+++ b/test/tests/dip_io/test_xml.py	Wed Aug 04 17:27:49 2010 -0400
@@ -142,7 +142,9 @@
         """ Test an Instance attribute. """

         class Klass(Model):
-            attr = Instance(SubModel)
+            #attr = Instance(SubModel)
+            def __init__(self, attr=None):
+                self.attr = attr

         storage = storage_factory()

        m_write = Klass(attr=SubModel())

However, after making this change, this test fails:

ERROR: test_Instance (tests.dip_io.test_xml.TestModel)
Test an Instance attribute.
Traceback (most recent call last):
  File "/Users/darren/Projects/dip/test/tests/dip_io/test_xml.py",
line 156, in test_Instance
    self.assertEquals(m_read.attr.value, m_write.attr.value)
AttributeError: 'NoneType' object has no attribute 'value'

We work on a lot of different kinds of projects, and the experiments
are constantly changing. As a result, we are unfortunately very
closely tied to the details of the storage format. Still, it would be
nice to have an interface that can read one format, and write another.
Is this possible to do this with dip, given my unusual circumstances?


More information about the PyQt mailing list