Commits

Christian Scholz committed 61259ee

added controller for serving profile pictures.
missing: 404 on not findable profile pics

  • Participants
  • Parent commits e713586

Comments (0)

Files changed (1)

File adhocracy/controllers/profilepics.py

+from pylons.i18n import _
+from pylons import config
+
+import quantumcore.storages
+
+from adhocracy.lib.base import *
+
+log = logging.getLogger(__name__)
+
+class ProfilepicsController(BaseController):
+    
+    def serve(self, filename):
+        fs_location = config.get('adhocracy.profile_pic.dir', '/tmp/')
+        fs = quantumcore.storages.FilesystemStore(fs_location,"")
+        try:
+            f = fs[filename]
+            mtime = fs.get_mtime(filename)
+        except KeyError:
+            return "okoko"
+        return render_png(f.read(), mtime, content_type="image/png")