]> git.parisson.com Git - telemeta.git/commitdiff
Update calls against TimeSide 0.7
authorGuillaume Pellerin <yomguy@parisson.com>
Sun, 18 Jan 2015 23:54:30 +0000 (00:54 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Sun, 18 Jan 2015 23:54:30 +0000 (00:54 +0100)
Add TELEMETA_STRICT_CODE in settings to override strict item code checking

example/sandbox/settings.py
telemeta/models/media.py
telemeta/views/core.py
telemeta/views/item.py

index 1d8ea08b9be8de7d034e013757144489ef47f669..f4de97fa4861f157d8eaa51e9083ac80c055324a 100644 (file)
@@ -182,6 +182,8 @@ TELEMETA_STREAMING_FORMATS = ('mp3', 'ogg')
 TELEMETA_DOWNLOAD_FORMATS = ('wav', 'mp3', 'ogg', 'flac')
 TELEMETA_PUBLIC_ACCESS_PERIOD = 51
 
+TELEMETA_STRICT_CODE = False
+
 AUTH_PROFILE_MODULE = 'telemeta.userprofile'
 SESSION_EXPIRE_AT_BROWSER_CLOSE = False
 
index c2d21e89bef487053053bb95400591ff9f85894e..32bcb9a1cfc5324f9ea2ed37093e57801d533c98 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2007-2010 Samalyse SARL
+# Copyright (C) 2010 Samalyse SARL
 # Copyright (C) 2010-2014 Parisson SARL
 
 # This software is a computer program whose purpose is to backup, analyse,
@@ -61,6 +61,8 @@ from django.contrib.sites.models import Site
 from django.forms.models import model_to_dict
 
 
+strict_code = getattr(settings, 'TELEMETA_STRICT_CODE', False)
+
 # Special code regex of collections for the branch
 collection_published_code_regex = getattr(settings, 'COLLECTION_PUBLISHED_CODE_REGEX', '[A-Za-z0-9._-]*')
 collection_unpublished_code_regex = getattr(settings, 'COLLECTION_UNPUBLISHED_CODE_REGEX', '[A-Za-z0-9._-]*')
@@ -534,9 +536,10 @@ class MediaItem(MediaResource):
         return False
 
     def clean(self):
-        if self.code and not self.is_valid_code(self.code):
-            raise ValidationError("%s is not a valid item code for collection %s"
-                                        % (self.code, self.collection.code))
+        if strict_code:
+            if self.code and not self.is_valid_code(self.code):
+                raise ValidationError("%s is not a valid item code for collection %s"
+                                            % (self.code, self.collection.code))
 
     def save(self, force_insert=False, force_update=False):
         super(MediaItem, self).save(force_insert, force_update)
index 335191f68e8a68380d3d0db2a30e5118b16758fc..984e85f231f0445dde1123264f248b63a78562cd 100644 (file)
@@ -43,7 +43,6 @@ import random
 import datetime
 import tempfile
 import zipfile
-import timeside
 import mimetypes
 
 from jsonrpc import jsonrpc_method
index b9b1a961d7d6231226b1acfc977c8d5e1bd43095..ffc4ddf8e62a1a0ffaa79062b3844beac2d0b0a8 100644 (file)
 
 
 from telemeta.views.core import *
+import timeside.core
 
 
 class ItemBaseMixin(object):
 
-    graphers = timeside.core.processors(timeside.api.IGrapher)
-    decoders = timeside.core.processors(timeside.api.IDecoder)
-    encoders = timeside.core.processors(timeside.api.IEncoder)
-    analyzers = timeside.core.processors(timeside.api.IAnalyzer)
-    value_analyzers = timeside.core.processors(timeside.api.IValueAnalyzer)
+    graphers = timeside.core.processor.processors(timeside.core.api.IGrapher)
+    decoders = timeside.core.processor.processors(timeside.core.api.IDecoder)
+    encoders = timeside.core.processor.processors(timeside.core.api.IEncoder)
+    analyzers = timeside.core.processor.processors(timeside.core.api.IAnalyzer)
+    value_analyzers = timeside.core.processor.processors(timeside.core.api.IValueAnalyzer)
     cache_data = TelemetaCache(settings.TELEMETA_DATA_CACHE_DIR)
     cache_export = TelemetaCache(settings.TELEMETA_EXPORT_CACHE_DIR)
 
@@ -382,7 +383,7 @@ class ItemView(ItemBaseMixin):
 
             source = item.get_source()
             if source:
-                decoder  = timeside.decoder.file.FileDecoder(source)
+                decoder = timeside.core.get_processor('file_decoder')(source)
                 pipe = decoder
 
                 for analyzer in self.value_analyzers:
@@ -491,7 +492,7 @@ class ItemView(ItemBaseMixin):
             source = item.get_source()
             if source:
                 path = self.cache_data.dir + os.sep + image_file
-                decoder  = timeside.decoder.file.FileDecoder(source)
+                decoder = timeside.core.get_processor('file_decoder')(source)
                 graph = grapher(width=width, height=height)
                 (decoder | graph).run()
                 graph.watermark('timeside', opacity=.6, margin=(5,5))
@@ -579,7 +580,7 @@ class ItemView(ItemBaseMixin):
             media = self.cache_export.dir + os.sep + file
             if not self.cache_export.exists(file) or not flag.value:
                 # source > encoder > stream
-                decoder = timeside.decoder.file.FileDecoder(source)
+                decoder = timeside.core.get_processor('file_decoder')(source)
                 proc = encoder(media, streaming=True, overwrite=True)
                 if extension in mapping.unavailable_extensions:
                     metadata=None
@@ -867,7 +868,7 @@ class ItemDetailView(ItemViewMixin, DetailView):
 
             source = item.get_source()
             if source:
-                decoder  = timeside.decoder.file.FileDecoder(source)
+                decoder  = timeside.core.get_processor('file_decoder')(source)
                 pipe = decoder
 
                 for analyzer in self.value_analyzers: