'This is called whenever a session has been resynced with the
portal.  At this point all relevant attributes have already
been set and self.player been assigned (if applicable).
Since this is often called after a server restart we need to
set up the session as it was.'

def at_sync(self):

    global _ObjectDB
    if (not _ObjectDB):
        from evennia.objects.models import ObjectDB as _ObjectDB
    if (not self.logged_in):
        self.cmdset_storage = settings.CMDSET_UNLOGGEDIN
    self.cmdset.update(init_mode=True)
    if self.puid:
        obj = _ObjectDB.objects.get(id=self.puid)
        obj.sessions.add(self)
        obj.player = self.player
        self.puid = obj.id
        self.puppet = obj
        obj.locks.cache_lock_bypass(obj)
