def insert(cls, _name, _ts):
		version_query = AppVersion.all()
		version_query.filter('name =', _name.strip())
		versions = []
		versions = version_query.fetch(1)
		if versions:
			version = versions[0]
			if _ts and _ts.tzinfo == None:
				_ts = pytz.utc.localize(_ts)
			if pytz.utc.localize(version.lastIncident) < _ts:
				version.lastIncident = _ts
				logging.info("version " + version.name + " last incident: " + version.lastIncident.strftime(r"%d/%m/%Y %H:%M:%S %Z"))
			version.crashCount = version.crashCount + 1
			version.put()
			cacheId = "CrashReport%s_counter" % version.name
			memcache.set(cacheId, version.crashCount, 432000)
		else:
			def vcmp(x, y):
				gx = re.match(r'^([0-9.]+)((?:alpha|beta)?)((?:\d+)?)((?:\D.*)?)$', x).groups()
				gy = re.match(r'^([0-9.]+)((?:alpha|beta)?)((?:\d+)?)((?:\D.*)?)$', y).groups()
				revx = 0 if len(gx[2]) == 0 else int(gx[2])
				revy = 0 if len(gy[2]) == 0 else int(gy[2])
				return -cmp("%s%sz%04d%s" % (gx[0], gx[1], revx, gx[3]), "%s%sz%04d%s" % (gy[0], gy[1], revy, gy[3]))
			nv = AppVersion(name = _name.strip(), lastIncident = _ts, crashCount = 1)
			nv.put()
			cacheId = "CrashReport%s_counter" % nv.name
			memcache.set(cacheId, 1, 432000)
			Cnt.incr("AppVersion_counter")
			Lst.append('all_version_names_list', nv.name, vcmp)
    def insert(cls, _name, _ts):
        version_query = AppVersion.all()
        version_query.filter('name =', _name.strip())
        versions = []
        versions = version_query.fetch(1)
        if versions:
            version = versions[0]
            if _ts and _ts.tzinfo == None:
                _ts = pytz.utc.localize(_ts)
            if pytz.utc.localize(version.lastIncident) < _ts:
                version.lastIncident = _ts
                logging.info(
                    "version " + version.name + " last incident: " +
                    version.lastIncident.strftime(r"%d/%m/%Y %H:%M:%S %Z"))
            version.crashCount = version.crashCount + 1
            version.put()
            cacheId = "CrashReport%s_counter" % version.name
            memcache.set(cacheId, version.crashCount, 432000)
        else:

            def vcmp(x, y):
                gx = re.match(
                    r'^([0-9.]+)((?:alpha|beta)?)((?:\d+)?)((?:\D.*)?)$',
                    x).groups()
                gy = re.match(
                    r'^([0-9.]+)((?:alpha|beta)?)((?:\d+)?)((?:\D.*)?)$',
                    y).groups()
                revx = 0 if len(gx[2]) == 0 else int(gx[2])
                revy = 0 if len(gy[2]) == 0 else int(gy[2])
                return -cmp("%s%sz%04d%s" %
                            (gx[0], gx[1], revx, gx[3]), "%s%sz%04d%s" %
                            (gy[0], gy[1], revy, gy[3]))

            nv = AppVersion(name=_name.strip(), lastIncident=_ts, crashCount=1)
            nv.put()
            cacheId = "CrashReport%s_counter" % nv.name
            memcache.set(cacheId, 1, 432000)
            Cnt.incr("AppVersion_counter")
            Lst.append('all_version_names_list', nv.name, vcmp)