public
Description: A full featured and opinionated blogging solution using Django
Homepage: http://lethain.com/projects/lifeflow/
Clone URL: git://github.com/lethain/lifeflow.git
File uploads and display in LFE now updated to Django Beta 2 API.
lethain (author)
Wed Aug 27 09:31:43 -0700 2008
commit  704dd6df898fb8b81c79106cdf07c257f29511b9
tree    31b87ba3dc6100101fb32d6f90d494a7d86df419
parent  75a32f85f550779eb02e73c68281bdd1afc2b5f5
...
274
275
276
277
 
278
279
280
281
282
283
284
 
285
286
287
...
299
300
301
302
 
303
304
305
306
307
 
308
309
 
 
310
311
312
...
324
325
326
327
 
328
329
330
...
333
334
335
336
 
337
338
339
...
341
342
343
344
 
345
346
347
...
274
275
276
 
277
278
279
280
281
282
283
 
284
285
286
287
...
299
300
301
 
302
303
304
305
306
307
308
309
 
310
311
312
313
314
...
326
327
328
 
329
330
331
332
...
335
336
337
 
338
339
340
341
...
343
344
345
 
346
347
348
349
0
@@ -274,14 +274,14 @@ def create_model(request):
0
 def add_author_picture(request):
0
     id = request.POST['pk']
0
     file = request.FILES['file']
0
-    filename = file['filename']
0
+    filename = file.name
0
     filebase = '%s/lifeflow/author/' % settings.MEDIA_ROOT
0
     filepath = "%s%s" % (filebase, filename)
0
     while (os.path.isfile(filepath)):
0
         filename = "_%s" % filename
0
         filepath = "%s%s" % (filebase, filename)
0
     fd = open(filepath, 'wb')
0
-    fd.write(file['content'])
0
+    fd.write(file.read())
0
     fd.close()
0
     
0
     author = Author.objects.get(pk=id)
0
@@ -299,14 +299,16 @@ def add_resource(request):
0
     file = request.FILES['file']
0
     title = request.POST['title']
0
     markdown_id = request.POST['markdown_id']
0
-    filename = file['filename']
0
+    filename = file.name
0
     filebase = '%s/lifeflow/resource/' % settings.MEDIA_ROOT
0
     filepath = "%s%s" % (filebase, filename)
0
     while (os.path.isfile(filepath)):
0
         filename = "_%s" % filename
0
         filepath = "%s%s" % (filebase, filename)
0
+    print filepath
0
     fd = open(filepath, 'wb')
0
-    fd.write(file['content'])
0
+
0
+    fd.write(file.read())
0
     fd.close()
0
     rec = Resource(title=title, markdown_id=markdown_id, content="lifeflow/resource/%s" % filename)
0
     rec.save()
0
@@ -324,7 +326,7 @@ CODE_EXTS = ["css", "html", "htm", "c", "o", "py", "lisp", "js", "xml",
0
 @login_required
0
 def display_resource(request, id):
0
     res = Resource.objects.get(pk=id)
0
-    file = res.content.split("/")[-1]
0
+    file = res.content.path.split("/")[-1]
0
     opts = {'object':res,'file':file}
0
     ext = opts['file'].split(".")[-1]
0
     opts['type'] = 'file'
0
@@ -333,7 +335,7 @@ def display_resource(request, id):
0
     elif ext in ZIP_EXTS:
0
         try:
0
             opts['type'] = "zip"
0
-            zf = ZipFile(res.get_content_filename(),'r')
0
+            zf = ZipFile(res.content.path,'r')
0
             opts['files_list'] = zf.namelist()
0
             zf.close()
0
         except IOError:
0
@@ -341,7 +343,7 @@ def display_resource(request, id):
0
     else:
0
         try:
0
             lexer = get_lexer_for_filename(file)
0
-            f = open(res.get_content_filename(),'r')
0
+            f = open(res.content.path,'r')
0
             data = f.read()
0
             f.close()
0
             opts['highlighted_code'] = highlight(data,lexer,HtmlFormatter())
...
307
308
309
310
 
311
312
313
...
415
416
417
418
 
419
420
421
...
476
477
478
479
 
480
481
482
...
307
308
309
 
310
311
312
313
...
415
416
417
 
418
419
420
421
...
476
477
478
 
479
480
481
482
0
@@ -307,7 +307,7 @@ class Flow(models.Model):
0
 
0
 
0
 class Language(models.Model):
0
-    title = models.CharField(max_length=50, core=True)
0
+    title = models.CharField(max_length=50)
0
     slug = models.SlugField()
0
 
0
     def __unicode__(self):
0
@@ -415,7 +415,7 @@ class Series(models.Model):
0
     """
0
     A series is a collection of Entry instances on the same theme.
0
     """
0
-    title = models.CharField(max_length=200, core=True)
0
+    title = models.CharField(max_length=200)
0
     slug= models.SlugField()
0
 
0
     class Meta:
0
@@ -476,7 +476,7 @@ class SiteToNotify(models.Model):
0
 
0
 class Tag(models.Model):
0
     "Tags are associated with Entry instances to describe their contents."
0
-    title = models.CharField(max_length=50, core=True)
0
+    title = models.CharField(max_length=50)
0
     slug = models.SlugField()
0
 
0
 

Comments