EnumProperty fill dynamically using callback Fellow pythons, greetings. I am trying to create a dynamic Enum property that lists all objects on the scene with a certain custom property. However, whenever a new object is created on the scene (and thus enum is changed automatically including the order of the items in it), it shuffles the values of already selected properties and breaks my whole script workflow. Is there a way to avoid that or use anything else to perform a similar task?

Here is my code:

###############################
## Portal plane
###############################

def GetGroupObjectsReferences(self, context):

    groups = []
    groups.append(('0', "None", "")) # setting a default entry as a first element of our enum

    for obj in bpy.context.scene.objects:
        if obj.WowWMOGroup.Enabled:
            groups.append((obj.name, obj.name, ""))

    return groups

''' 
def UpdateFirstGroupObjectReference(self, context):

    if context.object.WowPortalPlane.First == context.object.WowPortalPlane.Second and context.object.WowPortalPlane.First != '0':
        context.object.WowPortalPlane.Second = '0'          

def UpdateSecondGroupObjectReference(self, context):

    if context.object.WowPortalPlane.Second == context.object.WowPortalPlane.First and context.object.WowPortalPlane.Second != '0':
        context.object.WowPortalPlane.First = '0'
'''


class WowPortalPlanePanel(bpy.types.Panel):
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"
    bl_label = "Wow Portal Plane"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_header(self, context):
        layout = self.layout
        self.layout.prop(context.object.WowPortalPlane, "Enabled")

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        layout.enabled = context.object.WowPortalPlane.Enabled
        self.layout.prop(context.object.WowPortalPlane, "First")
        self.layout.prop(context.object.WowPortalPlane, "Second")     

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

class WowPortalPlanePropertyGroup(bpy.types.PropertyGroup):
    Enabled = bpy.props.BoolProperty(name="", description="Enable wow WMO group properties")
    First = bpy.props.EnumProperty(items=GetGroupObjectsReferences, name="First group", description="First group")
    Second = bpy.props.EnumProperty(items=GetGroupObjectsReferences, name="Second group", description="Second group")
    PortalID = bpy.props.IntProperty(name="Portal's ID", description="Portal ID")

def RegisterWowPortalPlaneProperties():
    bpy.types.Object.WowPortalPlane = bpy.props.PointerProperty(type=WowPortalPlanePropertyGroup)

def UnregisterWowPortalPlaneProperties():
    bpy.types.Object.WowPortalPlane = None


Thank you in advance for help.
Since Blender 2.79 you can do the following.

###############################
## Portal plane
###############################

def is_wowgroup_enabled(self, obj):
    return obj.WowWMOGroup.Enabled


class WowPortalPlanePanel(bpy.types.Panel):
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "object"
    bl_label = "Wow Portal Plane"
    bl_options = {'DEFAULT_CLOSED'}

    def draw_header(self, context):
        layout = self.layout
        self.layout.prop(context.object.WowPortalPlane, "Enabled")

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        layout.enabled = context.object.WowPortalPlane.Enabled
        self.layout.prop(context.object.WowPortalPlane, "First")
        self.layout.prop(context.object.WowPortalPlane, "Second")     

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


class WowPortalPlanePropertyGroup(bpy.types.PropertyGroup):
    Enabled = bpy.props.BoolProperty(name="", description="Enable wow WMO group properties")
    First = bpy.props.PointerProperty(type=bpy.types.Object, poll=is_wowgroup_enabled, name="First group", description="First group")
    Second = bpy.props.PointerProperty(type=bpy.types.Object, poll=is_wowgroup_enabled, name="Second group", description="Second group")
    PortalID = bpy.props.IntProperty(name="Portal's ID", description="Portal ID")


def RegisterWowPortalPlaneProperties():
    bpy.types.Object.WowPortalPlane = bpy.props.PointerProperty(type=WowPortalPlanePropertyGroup)


def UnregisterWowPortalPlaneProperties():
    bpy.types.Object.WowPortalPlane = None