[Dev] how do I use an AssetDictionary?

James Paige Bob at HamsterRepublic.com
Fri Apr 11 09:45:03 PDT 2008


On Thu, Apr 10, 2008 at 08:35:23PM -0700, Brian Fisher wrote:
> The idea is to do something like this:
> -------------------------------
> class HasDictProperty(AssetBase):
>     myDict = AssetDict(AssetObject(ObjectInDict))
> 
> -----
> and then you could access myDict on an instance of HasDictProperty
> just as a normal dictionary. However I never made it work in that I
> never made the editor understand it and I never made anything that
> tests it really.

Hmmm... that is how I thought it worked, but when I try it, it does 
this:

james at doomtrain:~/src/mhgames/marauders$ ./main.py
Traceback (most recent call last):
  File \"./main.py\", line 7, in <module>
    from map import BaseMap
  File \"/home/james/src/mhgames/marauders/map.py\", line 24, in 
<module>
    class BaseMap(AssetBase):
  File \"/home/james/src/mhgames/marauders/map.py\", line 26, in BaseMap
    data = AssetDictionary(AssetObject(Tile))
  File 
\"/usr/lib/python2.5/site-packages/motherhamster/cheekpouches.py\", line 
394, in __init__
    assert(isinstance(element_descriptor, SimpleProperty))
AssertionError


> For the editor, the idea is it would provide areas to enter keys and
> delete entries and all that, and would create the appropriate editor
> for the element in the dictionary based on the AssetType specified as
> an argument to the AssetDict property descriptor (i.e. in the case
> above it would make an editor that let you edit the properties of the
> ObjectInDict instance in the dictionary)

Sounds reasonable. I am actually not currently interested in the editor 
interface for it, I just want the serialization and deserialization.

---
James

> For testing it's functionality, I would expect it saves and loads no
> problem, and that code access of the Dict works just fine - I just
> haven't really proofed it out to say 100% that it would.
>
> On Thu, Apr 10, 2008 at 8:07 PM, James Paige <Bob at hamsterrepublic.com> wrote:
> > Hey, Brian. How does the AssetDictionary work? I would like to store an
> >  asset with a property that contains a dictionary of Tile assets with
> >  (x,y) tuples as the keys.
> >
> >  ---
> >  James
> >  _______________________________________________
> >  Dev mailing list
> >  Dev at lists.motherhamster.org
> >  http://lists.motherhamster.org/listinfo.cgi/dev-motherhamster.org
> >
> _______________________________________________
> Dev mailing list
> Dev at lists.motherhamster.org
> http://lists.motherhamster.org/listinfo.cgi/dev-motherhamster.org
> 
> 



More information about the Dev mailing list