def _import_room(request, acc, r): modified = False room = None if room and (abs(room.lastupdate() - time.time()) < settings.IMPORT_TTL): return room if r.has_key('urlpath'): r['urlpath'] = r['urlpath'].strip('/') try: room = Room.by_sco(r['sco']) for key in ('sco', 'name', 'source_sco', 'urlpath', 'description', 'user_count', 'host_count'): if r.has_key(key) and hasattr(room, key): rv = getattr(room, key) if rv != r[key] and r[key] is not None and r[key]: setattr(room, key, r[key]) modified = True if modified: logging.debug("+++ saving room ... %s" % pformat(room)) room.save() except ObjectDoesNotExist: if r['folder_sco']: try: room = Room.objects.create(sco=r['sco'], source_sco=r['source_sco'], name=r['name'], urlpath=r['urlpath'], description=r['description'], creator=request.user, folder_sco=r['folder_sco']) except Exception, e: room = None pass