CollectionProperty initialization i need to initialize a CollectionProperty with a fixed number of items. This property is 
used to store slot data, kind of like texture slots (There is 18 slots avaibles, but even if they are empty, they exist in the slot collection). Not sure if i am very clear so here is a bit of code

class MyPanel(bpy.types.Panel):
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "world"
    bl_label = "my panel"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_header(self, context):
        layout = self.layout

    def draw(self, context):
        layout = self.layout
        row = layout.row()

        ob = context.active_object

        # tried to initialize the collection here but i get the error "Writing to ID classes in this context is not allowed"
        """if(len(ob.test.myslots) &lt; 4):
            for i in range(len(ob.test.myslots), 4):
                ob.test.myslots.add()"""
    # MyUIList inherit from bpy.types.UIList
        layout.template_list("MyUIList", "", ob.test, "myslots", ob.test, "myslots_active", rows=4, maxrows=4)

    @classmethod
    def poll(cls, context):
        return (context.active_object is not None and context.active_object.data is not None and isinstance(context.active_object.data, bpy.types.Mesh))


class MySlot(bpy.types.PropertyGroup):
    slotName = bpy.props.StringProperty()

class MyProperty(bpy.types.PropertyGroup):
    myslots = bpy.props.CollectionProperty(type=MySlot)
    myslots_active = bpy.props.IntProperty()

bpy.types.Object.test = bpy.props.PointerProperty(type=MyProperty)


How do I inititalize this list so...?
You can't, you need to have an explicit operation to initialize the list. (a button for example), or when the script executes.

At least you can't do while drawing.