Extend CollectionProperty Class


Is there any way to extend a CollectionProperty class?. I have the following problem.

Im writing an addon that reads and writes to a custom xml wrapper class but it fails on register, getting RestrictContext or RestrictData errors.

#A custom collection class
class myItems():
   __items = []
  def __init__(self):
  def add(self):

class myAddonProperties(bpy.types.PropertyGroup):
    myAddonItems = myItems()


bpy.types.scene.myAddon = PointerProperty(myAddonProperties)

It fails on enable the addon getting RestrictContext error

class ItemProperties(bpy.types.PropertyGroup):

class myCollection(CollectionProperty):
    def __init__(self, type):
        self.type = type
    def __call__(self, type):
        self.type = type

class myAddonProperties(bpy.types.PropertyGroup):

    myItems = myCollection(type = ItemProperties)

The first example works fine if its executed from the text editor but they fail when they are loaded as an addon.
The real question is, is it posible to write an addon that has a custom class that reads and writes to Blender classes?

PD: Im accesing myItems from the propertygroup as self.myItems, will it work if i access myItems as myAddonProperties.myItems?

I have successfully extended a collection via threading. I put detection code in the draw event of a panel. When I detect that the collection is empty or none I launch a thread to do the work.

This is not ideal but it does work. All my recent AddOns contain this mechanism.

Yes is ugly but works, i was hoping it would be a better way like inherit from some kind of RNA class in order to allow such operations or custom classes. Thanks Atom.