def create_from_fs(path): """ update theme info from filesystem """ theme_info_file = os.path.join(path, 'theme.info') directory_name = os.path.basename(path) ref = Theme.get(directory_name=directory_name) if ref: return False if os.path.isfile(theme_info_file): config = ConfigParser.ConfigParser() config.read(theme_info_file) theme_name = config.get(ConfigParser.DEFAULTSECT, 'name', directory_name) theme_description = config.get(ConfigParser.DEFAULTSECT, 'description') else: theme_name = directory_name theme_description = '' params = {'name': theme_name, 'description': theme_description, 'installed': True, 'active': False, 'directory_name': directory_name} theme_ref = Theme(**params) return theme_ref.put()
def check_themes(): """ check themes found in file system and compare with registered one in database """ # first disable all themes for theme in Theme.all(): theme.installed = False theme.put() # now look for all themes in filesystem and enable them for theme_dir, theme_path in get_theme_dirs(): #theme, created = Theme.objects.get_or_create(directory_name=theme_dir) create_from_fs(theme_path) active_theme = Theme.get_active() if not active_theme: ref = Theme.get(directory_name=settings.DEFAULT_THEME) ref.active = True ref.put()