2007年05月16日 星期三 11:46
ÎÒÔÚÓÃdjangoÉÏ´«Îļþʱ£¬Ïë¸øÎļþÖØÃüÃû£¬Òò´ËʹÓÃÁË,djangoÌṩµÄsave_FOO_file(filename, raw_contents),µ«ÊÇ£¬ÉÏ´«Ê±£¬ÉÏ´«µÄÎļþ»áÒ»Ö±Éú³É¶à¸ö. eg: ÎļþÃûΪ: 123.mov, 123_.mov, 123__.mov..... Èç¹û²»Öжϣ¬Ëü»áÒ»Ö±Éú³É£¬ÎªÊ²Ã´£¬¸ÃÔõÑù½â¾ö£¿ ÎÒµÄmodelsÈçÏÂ: class Video(models.Model): videoupload = models.FileField(upload_to='/home/purpen/video') comment = models.CharField(maxlength=250,blank=True) flvfilename = models.CharField(maxlength=250,blank=True,null=True) def save(self): content = open(self.get_videoupload_filename(), 'rb').read( self.get_videoupload_size()) super(Video, self).save() self.save_videoupload_file('te.mov',content) ¶àл´óÏÀÖ¸µã£¡ -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/c5a385da/attachment.htm
2007年05月16日 星期三 11:51
д½øÊý¾Ý¿âÀïµÄÊÇ×îºóÒ»¸öÎļþÃû,¼´ÊÖ¶¯ÖжÏÀïµÄÄǸö123_______________....mov ÔÚ07-5-16£¬xiaoyi tian <purpen.w在gmail.com> дµÀ£º > > ÎÒÔÚÓÃdjangoÉÏ´«Îļþʱ£¬Ïë¸øÎļþÖØÃüÃû£¬Òò´ËʹÓÃÁË,djangoÌṩµÄsave_FOO_file(filename, > raw_contents),µ«ÊÇ£¬ÉÏ´«Ê±£¬ÉÏ´«µÄÎļþ»áÒ»Ö±Éú³É¶à¸ö. > > eg: > ÎļþÃûΪ: 123.mov, 123_.mov, 123__.mov..... > Èç¹û²»Öжϣ¬Ëü»áÒ»Ö±Éú³É£¬ÎªÊ²Ã´£¬¸ÃÔõÑù½â¾ö£¿ > > ÎÒµÄmodelsÈçÏÂ: > > class Video( models.Model): > videoupload = models.FileField(upload_to='/home/purpen/video') > comment = models.CharField(maxlength=250,blank=True) > flvfilename = models.CharField(maxlength=250,blank=True,null=True) > > def save(self): > content = open(self.get_videoupload_filename(), 'rb').read( > self.get_videoupload_size()) > super(Video, self).save() > self.save_videoupload_file('te.mov',content) > > ¶àл´óÏÀÖ¸µã£¡ > > > -- > ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/9b49e106/attachment.html
2007年05月16日 星期三 12:33
On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 写进数据库里的是最后一个文件名,即手动中断里的那个123_______________....mov > 存在死循环的情况吗?django在保存时会自动进行安全处理,主要就是将非ascii码去掉,然后判断上传目录下是否有同名的文件,如果有,则加上'_',再判断,直到没有同名的文件。因此如果有死循环,它会一直保存,再保存。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年05月16日 星期三 12:52
³ö´íÈçÏ£º Exception happened during processing of request from ('127.0.0.1', 35206) Unhandled exception in thread started byTraceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1192, in inner_run run(addr, int(port), handler) File "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", line 642, in run httpd.serve_forever() File "SocketServer.py", line 201, in serve_forever File "SocketServer.py", line 224, in handle_request File "SocketServer.py", line 269, in handle_error ImportError: No module named traceback ¸ÃÔõÑù½â¾öÄØ£¿ ÔÚ07-5-16£¬limodou <limodou在gmail.com> дµÀ£º > > On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > д½øÊý¾Ý¿âÀïµÄÊÇ×îºóÒ»¸öÎļþÃû,¼´ÊÖ¶¯ÖжÏÀïµÄÄǸö123_______________....mov > > > > ´æÔÚËÀÑ»·µÄÇé¿öÂð£¿djangoÔÚ±£´æʱ»á×Ô¶¯½øÐа²È«´¦Àí£¬Ö÷Òª¾ÍÊǽ«·ÇasciiÂëÈ¥µô£¬È»ºóÅжÏÉÏ´«Ä¿Â¼ÏÂÊÇ·ñÓÐͬÃûµÄÎļþ£¬Èç¹ûÓУ¬Ôò¼ÓÉÏ'_'£¬ÔÙÅжϣ¬Ö±µ½Ã»ÓÐͬÃûµÄÎļþ¡£Òò´ËÈç¹ûÓÐËÀÑ»·£¬Ëü»áÒ»Ö±±£´æ£¬ÔÙ±£´æ¡£ > > -- > I like python! > UliPad < >: http://wiki.woodpecker.org.cn/moin/UliPad > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/4f3e23d2/attachment.html
2007年05月16日 星期三 12:56
On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 出错如下: > > Exception happened during processing of request from ('127.0.0.1', 35206) > Unhandled exception in thread started by> Traceback (most recent call last): > File > "/usr/lib/python2.4/site-packages/django/core/management.py", > line 1192, in inner_run > run(addr, int(port), handler) > File > "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", > line 642, in run > httpd.serve_forever() > File "SocketServer.py", line 201, in serve_forever > File "SocketServer.py", line 224, in handle_request > File "SocketServer.py", line 269, in handle_error > ImportError: No module named traceback > > 该怎样解决呢? > 这个是不是你的环境有问啊。traceback是python的标准模块,怎么会导不进去呢? -- I like python! UliPad < >: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年05月16日 星期三 13:03
àÞ£¬¿ÉÄܲ»ÊÇÕâ¸ö´íÎóÒýÆðµÄ¡£ ÎÒÊÇʹÓõÄdjango×Ô´øµÄadmin¹ÜÀíϵͳ×öµÄ¡£Ö»ÊÇÖض¨ÒåÁË£¬save()·½·¨¡£ models¾ÍÊÇÕâÑùµÄ: class Video( models.Model): videoupload = models.FileField(upload_to='/home/purpen/video') comment = models.CharField(maxlength=250,blank=True) flvfilename = models.CharField(maxlength=250,blank=True,null=True) def save(self): content = open(self.get_videoupload_filename(), 'rb').read( self.get_videoupload_size()) super(Video, self).save() self.save_videoupload_file('te.mov',content) ÕâÓÐʲô´íÎóÂ𣿠ÄãÓбðµÄ·½·¨½â¾öÂ𣿠ÔÚ07-5-16£¬limodou <limodou在gmail.com> дµÀ£º > > On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > ³ö´íÈçÏ£º > > > > Exception happened during processing of request from ('127.0.0.1', > 35206) > > Unhandled exception in thread started by> 0xb7a197d4> > > Traceback (most recent call last): > > File > > "/usr/lib/python2.4/site-packages/django/core/management.py", > > line 1192, in inner_run > > run(addr, int(port), handler) > > File > > "/usr/lib/python2.4/site-packages/django/core/servers/basehttp.py", > > line 642, in run > > httpd.serve_forever() > > File "SocketServer.py", line 201, in serve_forever > > File "SocketServer.py", line 224, in handle_request > > File "SocketServer.py", line 269, in handle_error > > ImportError: No module named traceback > > > > ¸ÃÔõÑù½â¾öÄØ£¿ > > > Õâ¸öÊDz»ÊÇÄãµÄ»·¾³ÓÐÎÊ°¡¡£tracebackÊÇpythonµÄ±ê׼ģ¿é£¬Ôõô»áµ¼²»½øÈ¥ÄØ£¿ > > -- > I like python! > UliPad < >: http://wiki.woodpecker.org.cn/moin/UliPad > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/affa334b/attachment.htm
2007年05月16日 星期三 13:14
On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 噢,可能不是这个错误引起的。 > > 我是使用的django自带的admin管理系统做的。只是重定义了,save()方法。 > > models就是这样的: > > class Video( models.Model): > videoupload = models.FileField(upload_to='/home/purpen/video > ') > comment = models.CharField(maxlength=250,blank=True) > flvfilename = > models.CharField(maxlength=250,blank=True,null=True) > > def save(self): > content = open(self.get_videoupload_filename(), 'rb').read( > self.get_videoupload_size()) 这句话当第一次上传还不存在这个文件会如何呢?建议你先删除以前的文件,再保存。 > super(Video, self).save() > self.save_videoupload_file('te.mov',content) > > 这有什么错误吗? > > 你有别的方法解决吗? > -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年05月16日 星期三 13:22
²»Ðеģ¬¾ÍÊÇĿ¼ÖÐûÓÐÖØÃûµÄ£¬ËüÒ²»áÉú³ÉºÃ¶à***___.***µÄ¡£ ²»ÖªµÀÊÇʲôÔÒò? ÔÚ07-5-16£¬limodou <limodou在gmail.com> дµÀ£º > > On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > àÞ£¬¿ÉÄܲ»ÊÇÕâ¸ö´íÎóÒýÆðµÄ¡£ > > > > ÎÒÊÇʹÓõÄdjango×Ô´øµÄadmin¹ÜÀíϵͳ×öµÄ¡£Ö»ÊÇÖض¨ÒåÁË£¬save()·½·¨¡£ > > > > models¾ÍÊÇÕâÑùµÄ: > > > > class Video( models.Model): > > videoupload = models.FileField(upload_to='/home/purpen/video > > ') > > comment = models.CharField(maxlength=250,blank=True) > > flvfilename = > > models.CharField(maxlength=250,blank=True,null=True) > > > > def save(self): > > content = open(self.get_videoupload_filename(), 'rb').read( > > self.get_videoupload_size()) > > Õâ¾ä»°µ±µÚÒ»´ÎÉÏ´«»¹²»´æÔÚÕâ¸öÎļþ»áÈçºÎÄØ£¿½¨ÒéÄãÏÈɾ³ýÒÔÇ°µÄÎļþ£¬ÔÙ±£´æ¡£ > > > super(Video, self).save() > > self.save_videoupload_file('te.mov',content) > > > > ÕâÓÐʲô´íÎóÂ𣿠> > > > ÄãÓбðµÄ·½·¨½â¾öÂ𣿠> > > > -- > I like python! > UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/c7b7f95b/attachment.html
2007年05月16日 星期三 13:26
On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 不行的,就是目录中没有重名的,它也会生成好多***___.***的。 > > 不知道是什么原因? > 会不会是以前测试留下来的。你可以先全部删掉,再试一下,看一看一次会生成多个吗? -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年05月16日 星期三 13:34
²»»áµÄ£¬ÎÒ¾ÍÊÇÈ«²¿É¾³ýµÄ¡£ ÔÚ07-5-16£¬limodou <limodou在gmail.com> дµÀ£º > > On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > ²»Ðеģ¬¾ÍÊÇĿ¼ÖÐûÓÐÖØÃûµÄ£¬ËüÒ²»áÉú³ÉºÃ¶à***___.***µÄ¡£ > > > > ²»ÖªµÀÊÇʲôÔÒò? > > > »á²»»áÊÇÒÔÇ°²âÊÔÁôÏÂÀ´µÄ¡£Äã¿ÉÒÔÏÈÈ«²¿É¾µô£¬ÔÙÊÔһϣ¬¿´Ò»¿´Ò»´Î»áÉú³É¶à¸öÂ𣿠> > -- > I like python! > UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad > My Blog: http://www.donews.net/limodou > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/8e631937/attachment.html
2007年05月16日 星期三 13:35
ľͷ´óÏÀ£¬ÎÒµÄmodelsд·¨Ã»´í°É ÔÚ07-5-16£¬xiaoyi tian <purpen.w在gmail.com> дµÀ£º > > ²»»áµÄ£¬ÎÒ¾ÍÊÇÈ«²¿É¾³ýµÄ¡£ > > ÔÚ07-5-16£¬limodou <limodou在gmail.com> дµÀ£º > > > > On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > > ²»Ðеģ¬¾ÍÊÇĿ¼ÖÐûÓÐÖØÃûµÄ£¬ËüÒ²»áÉú³ÉºÃ¶à***___.***µÄ¡£ > > > > > > ²»ÖªµÀÊÇʲôÔÒò? > > > > > »á²»»áÊÇÒÔÇ°²âÊÔÁôÏÂÀ´µÄ¡£Äã¿ÉÒÔÏÈÈ«²¿É¾µô£¬ÔÙÊÔһϣ¬¿´Ò»¿´Ò»´Î»áÉú³É¶à¸öÂ𣿠> > > > -- > > I like python! > > UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad > > My Blog: http://www.donews.net/limodou > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > > -- > ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070516/c1b117f9/attachment.htm
2007年05月16日 星期三 13:39
On 5/16/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 木头大侠,我的models写法没错吧 > Model定义看不出什么,不过一般upload_to是相对于settings.py MEDIA_ROOT的相对路径,不过我想使用绝对路径也不会有问题。 至于save可能要进行调试才知道了看不出什么来。我自已倒是没有遇到过你说的问题,不过我也不使用django的admin,都是自已做,所以处理方式不一样。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年05月16日 星期三 18:27
问题在这里: super(Video, self).save() self.save_videoupload_file('te.mov',content) save_videoupload_file('te.mov',content) 又会调用self.save的方法,结果递归下去了,没完没了.... 要另外保存直接用open,write,close... ----- Original Message ----- From: xiaoyi tian To: python-chinese at lists.python.cn Sent: Wednesday, May 16, 2007 1:03 PM Subject: Re: [python-chinese]django 运用save_FOO_file()时出错? 噢,可能不是这个错误引起的。 我是使用的django自带的admin管理系统做的。只是重定义了,save()方法。 models就是这样的: class Video( models.Model): videoupload = models.FileField(upload_to='/home/purpen/video ') comment = models.CharField(maxlength=250,blank=True) flvfilename = models.CharField(maxlength=250,blank=True,null=True) def save(self): content = open(self.get_videoupload_filename(), 'rb').read( self.get_videoupload_size()) super(Video, self).save() self.save_videoupload_file('te.mov',content) 这有什么错误吗? 你有别的方法解决吗?
2007年05月17日 星期四 09:20
àÞ£¬½â¾öÁË£¬²»¹ýÓõÄrenameÖØÃüÃûµÄ·½·¨¡£¶àлlimodouºÍvccµÄÖ¸µã¡£ ÔÚ07-5-16£¬vcc <vcc在163.com> дµÀ£º > > ÎÊÌâÔÚÕâÀ > super(Video, self).save() > self.save_videoupload_file('te.mov',content) > > save_videoupload_file('te.mov',content) ÓÖ»áµ÷ÓÃself.saveµÄ·½·¨£¬½á¹ûµÝ¹éÏÂÈ¥ÁË£¬Ã»ÍêûÁË.... > ÒªÁíÍâ±£´æÖ±½ÓÓÃopen,write,close... > > ----- Original Message ----- > From: xiaoyi tian > To: python-chinese在lists.python.cn > Sent: Wednesday, May 16, 2007 1:03 PM > Subject: Re: [python-chinese]django ÔËÓÃsave_FOO_file()ʱ³ö´í£¿ > > > àÞ£¬¿ÉÄܲ»ÊÇÕâ¸ö´íÎóÒýÆðµÄ¡£ > > ÎÒÊÇʹÓõÄdjango×Ô´øµÄadmin¹ÜÀíϵͳ×öµÄ¡£Ö»ÊÇÖض¨ÒåÁË£¬save()·½·¨¡£ > > models¾ÍÊÇÕâÑùµÄ: > > class Video( models.Model): > videoupload = models.FileField(upload_to='/home/purpen/video > ') > comment = models.CharField(maxlength=250,blank=True) > flvfilename = models.CharField(maxlength=250,blank=True,null=True) > > def save(self): > content = open(self.get_videoupload_filename(), 'rb').read( > self.get_videoupload_size()) > super(Video, self).save() > self.save_videoupload_file('te.mov',content) > > ÕâÓÐʲô´íÎóÂ𣿠> > ÄãÓбðµÄ·½·¨½â¾öÂ𣿠> > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070517/64c6526a/attachment.html
Zeuux © 2025
京ICP备05028076号