老生 | 28 Mar 11:24 2007
Picon

django缓存机制?

这两天研究django缓存,实在恼火,
 
数据的缓存是没什么问题,即:设置 cache.set("test",data, 60*60*24),读取 cache.get("test"),
 
在views.py的方法前设置缓存如: <at> cache_page(10*60),执行提示 'function' object has no attribute 'method',
 
以上是在WIN上进行测试的,原本以为是setting.py文件中设置的缓存类型不支持,如:CACHE_BACKEND = 'locmem:///c:/tem/,而公司服务器上使用的linux系统,所以今天一整天就在linux环境来进行调试。。。。
 
安装memcached,启动,再进行测试,按照在win上设置 <at> cache_page(10*60)依然出现同样错误提示,如:'function' object has no attribute 'method'
 
换种方式,在urls.py中设置,如(r'^c(?P<cateid>\w+)-b1/$',cache_page(VerifyPostList,10*60)),不会出任何错误提示,这里不知道怎么来测试是否是在取缓存里的东西,所以用种很老土的方式测试,,
 
1、关闭memcached,重启机器,在urls.py中不设置缓存,打印程序执行时间,
 
2、开启memcached,重启机器,在urls.py中设置缓存,打印程序执行时间,
 
如此重复以上几个布置,NND,发现两种布置程序执行的时间都差不多,,,
 
网上查找了好多资料,包括英文 都没发现有django中cache实现原理的资料,看源码的话,想必大家都知道python中的源码实在是难看懂。。。
 
 
 
说了这么多,还是总结以下我的问题及想要了解的东西吧,
 
 
问题一:有兄弟用过 <at> cache_page并成功过的吗?
 
问题二:在views.py中定义的 <at> cache_page与在urls.py中定义的cache_page有什么不同?为何我以上调试测试程序的执行时间都一样?
 
问题三:想实现能找到cache_page中缓存页面的机制,即想在cache中找到缓存页面的key,这样或许有可能我们在后台程序里可以直接获得与修改这个key中的值。。
 
 
 
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Wei Jiang | 28 Mar 13:10 2007
Picon

Re: 读取excel表格,要看哪些资料?

这是以前一个报表项目写的库,仅供参考。

import win32com.client
import os
import time

class Excel:
    def __init__(self, filename=None, configuration = None):
 
        self.xApp = win32com.client.Dispatch('Excel.Application ')
        self.Config = configuration
        
        #start info.  
        #reading configuation file    
        print "Setting standard font: %s" % self.Config['FONT']
        self.xApp.StandardFont = self.Config['FONT']
        
        print "Setting standard size: %s" % str(TextSize)     
        self.xApp.StandardFontSize = TextSize

        #check configuration file       
        if os.path.exists( self.Config['DATAPATH'] ) :
            pass
        else:
            print "Error: The given data path doesn't exist"
            self.close()
        
        # name of report
        if filename:
            self.Filename = filename
            try:
                self.xBook = self.xApp.Workbooks.Open(filename)
            except:
                print "Error: Open file %s failed" % filename
        else:
                           
            self.xBook = self.xApp.Workbooks.Add()
            reportname = self.Config['PROJECT']+ '_R'+ self.Config['VERSION'] + '_' + time.strftime("%Y%m%d") + '_IssueReport'
            self.Filename = os.path.join( self.Config['PATH'], reportname)
            Name = self.Filename + '.xls'
      
          # if the file exists, rename new file as format oldname(number)
            try:
                if os.path.exists ( Name ):
                    number = 2
                    
                    # test new name
                    while 1:                            
                        Name = self.Filename + "(" + str(number) + ").xls"                        
                        if os.path.exists ( Name ):
                            number += 1    
                            continue
                        else :
                            break
                    
                    self.Filename = self.Filename + "(" + str(number) + ").xls"  
                    print "Given name has been used, rename new report to %s" % self.Filename
                else:
                    self.Filename += '.xls'
                    
                print "Report name: %s" % self.Filename   
                self.xBook.SaveAs( self.Filename )
                print "Report file was created"
            except:
                print "Error: creating file failed"

 
    def save(self, newfilename=None):
        
        print "Saving report to %s" % self.Config['PATH']
        if newfilename:
            self.Filename = newfilename
            self.xBook.SaveAs(newfilename)
        else:
            self.xBook.Save()
        print "Report saved"

 
    def close(self):
        self.xBook.Close(SaveChanges=0)
        # close error msg
        del self.xApp

    def show(self):
        print "Show generated report"
        self.xApp.Visible = 1
    
    def delSheet(self, sheet):
        sht = self.xBook.Worksheets(sheet)
        
        try:
            sht.Delete()
            print "sheet %s is deleted" % sheet
        except:
            print "Error: Delete sheet %s failed" % sheet

    def hide(self):
        self.xApp.Visible = 0
 
    # get value from cell
    def getCell(self,sheet, row, col):
        "Get value of one cell"
        sht = self.xBook.Worksheets(sheet)
        return sht.Cells (row, col).Value


    # set value for cell
    def setCell(self, sheet,  row, col, value=None, formula=None):
        
        sht = self.xBook.Worksheets(sheet)
        if formula :
                sht.Cells(row, col).Formula = formula
        else:
                sht.Cells(row, col).Value = value
 
 
    # return tuple
    def getRange(self, sheet, row1, col1, row2, col2):
        "return a 2d array ( i.e. tuple of tuples)"
        sht = self.xBook.Worksheets(sheet)
        return sht.Range(sht.Cells(row1, col1), sht.Cells(row2, col2)).Value

 
 
    # set tuple  for range
    def setRange(self, sheet, topRow, leftCol, data):
        '''
        set range data from a tuple
        '''      
        if type( data ) == types.TupleType:
            
            bottomRow = topRow + len(data) - 1
            rightCol = leftCol + len(data[0]) - 1
            length = len(data)
        else:
            bottomRow = topRow
            rightCol = leftCol
            length = 1
        sht = self.xBook.Worksheets(sheet)
        
        if( length > MaxAccept):    
            times = length/MaxAccept;
            i = 0;    
            # Multiple * MaxAccept data
            while( i < times ):
                
                sht.Range(
                sht.Cells (topRow + i*MaxAccept, leftCol),
                sht.Cells(topRow + (i+1)*MaxAccept - 1, rightCol)
                ).Value = data[i*MaxAccept: (i+1)*MaxAccept]
                
                i += 1
                
            # additional data besides Multiple MaxAccept
            sht.Range(
                sht.Cells(topRow + times * MaxAccept, leftCol),
                sht.Cells(bottomRow, rightCol)
                ).Value = data[times * MaxAccept:]
                
            
        else:
            sht.Range(
                sht.Cells(topRow, leftCol),
                sht.Cells(bottomRow, rightCol)
                ).Value = data
               


    # rename a work sheet
    def setSheetName(self, sheet, name):
        '''
        Rename a sheet
        '''
        sht = self.xBook.Worksheets(sheet)
        
        #logging    
        print "Rename sheet %s to %s" % ( sheet , name )
        sht.Name = name

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Wei Jiang | 28 Mar 13:12 2007
Picon

Re: python读word

Python.Programming.on.Win32

On 3/28/07, Li Chunhui <lich <at> dhc.com.cn> wrote:
大家好,想问一下,怎样用python读windows 下的word文档?

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Leo Jay | 28 Mar 13:16 2007
Picon

Re: [python-chinese] 網絡瞬斷問題怎麽解決?

On 3/28/07, zuggie <magicccc <at> gmail.com> wrote:
>
> 想問下大家,我用Python寫了一個程式,主要功能是抓取文件,並讀取内容判斷結果。因爲客戶端是2000系統,所以把程式放在服務器上了,在服務器上建立了一個網絡映射槃,客戶端產生的文件放到這個槃中。但是使用過一段時間后,發現網絡有時候會出現瞬間斷掉,馬上有連接上的情況,每次出現這個情況,Python程式就讀取不到映射槃中的文件。這種情況有時候在半夜發生,大家有什麽好方法可以處理這個問題?

文件先复制到本地再处理。复制的时候出问题就过一定的时间再复制。

不过最好的情况是用ftp,http之类的专门的文件共享协议。windows的网络映射好像不大好。
取文件的时候可以用wget之类的专门的下载工具。

这样你就不用在网络这一块花心思了。尤其是商用的程序的话,充分已有的成熟的工具是很重要的。

--

-- 
Best Regards,
Leo Jay
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Deng Patrick | 28 Mar 13:30 2007
Picon

Re: 哪位有在python2.5下正常能用boa-constructor安装包啊,发一个给我吧,谢谢了

谢谢回复,我的环境是WindosXP + Python2.5,并且安装了最新的wxPython(2.8吧),现在需要匹配的boa-constructor,下载来的0.44跑起来老是说什么什么找不到,烦死了。

在07-3-28,jessinio smith <jessinio <at> gmail.com> 写道:
你的是哪个系统呀?我装好的是deb包



On 3/28/07, Deng Patrick < kedeng19801002 <at> gmail.com> wrote:


---------- Forwarded message ----------
From: Deng Patrick < kedeng19801002 <at> gmail.com>
Date: 2007-3-28 下午3:09
Subject: 哪位有在python2.5下正常能用boa-constructor安装包啊,发一个给我吧,谢谢了
To: python-chinese <at> lists.python

哪位有在python2.5下正常能用boa-constructor安装包啊,发一个给我吧,谢谢了
 
折腾死人了

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to   python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--
注意身体,身体是革命的本钱!!

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Ralph Wen | 28 Mar 13:18 2007
Picon

Re: 我写的crawler Anole0.0.5发布了

很久不会来了
不知如何退订?

 
On 3/28/07, 马踏飞燕 <honeyday.mj <at> gmail.com> wrote:
想研究一下,怎么项目没有了?

在 06-7-14,bird devdoer<devdoer <at> gmail.com> 写道:
> bu zhichi
> 在06-7-14,张海 <zhanghaizj <at> eyou.com> 写道:
> > 支持断点续传么?
> > 我现在的网络不稳定,间隔1-2个小时就会断一次,支持么?
> > 错误回滚么?
> > bird devdoer 写道:
> > > 爬虫
> > >
> > > 在06-7-14,*wang yingqi* < wangyingqi <at> gmail.com
> > > <mailto:wangyingqi <at> gmail.com >> 写道:
> > >
> > >     做什么用的?:)
> > >
> > >     On 7/13/06, *bird devdoer* < devdoer <at> gmail.com
> > >     <mailto: devdoer <at> gmail.com>> wrote:
> > >
> > >     下载地址:http://project.mytianwang.cn/devdoer/anole/
> > >     <http://project.mytianwang.cn/devdoer/anole/>
> > >
> > >     --
> > >     devdoer
> > >     devdoer <at> gmail.com <mailto:devdoer <at> gmail.com>
> > >     http://project.mytianwang.cn/cgi-bin/blog
> > >
> > >     _______________________________________________
> > >     python-chinese
> > >     Post: send python-chinese <at> lists.python.cn
> > >     <mailto:python-chinese <at> lists.python.cn >
> > >     Subscribe: send subscribe to
> > >     python-chinese-request <at> lists.python.cn
> > >     <mailto: python-chinese-request <at> lists.python.cn>
> > >     Unsubscribe: send unsubscribe to
> > >     python-chinese-request <at> lists.python.cn
> > >     <mailto: python-chinese-request <at> lists.python.cn >
> > >     Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> > >
> > >     _______________________________________________
> > >     python-chinese
> > >     Post: send python-chinese <at> lists.python.cn
> > >     <mailto:python-chinese <at> lists.python.cn>
> > >     Subscribe: send subscribe to
> > >     python-chinese-request <at> lists.python.cn
> > >     <mailto:python-chinese-request <at> lists.python.cn>
> > >     Unsubscribe: send unsubscribe to
> > >     python-chinese-request <at> lists.python.cn
> > >     <mailto:python-chinese-request <at> lists.python.cn >
> > >     Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> > >
> > >
> > > --
> > > devdoer
> > > devdoer <at> gmail.com <mailto: devdoer <at> gmail.com>
> > > http://project.mytianwang.cn/cgi-bin/blog
> > >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese <at> lists.python.cn
> > > Subscribe: send subscribe to
> python-chinese-request <at> lists.python.cn
> > > Unsubscribe: send unsubscribe to
> python-chinese-request <at> lists.python.cn
> > > Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese <at> lists.python.cn
> > Subscribe: send subscribe to
> python-chinese-request <at> lists.python.cn
> > Unsubscribe: send unsubscribe to
> python-chinese-request <at> lists.python.cn
> > Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
> >
>
>
>
> --
> devdoer
>
> devdoer <at> gmail.com
> http://project.mytianwang.cn/cgi-bin/blog
> _______________________________________________
> python-chinese
> Post: send python-chinese <at> lists.python.cn
> Subscribe: send subscribe to
> python-chinese-request <at> lists.python.cn
> Unsubscribe: send unsubscribe to
> python-chinese-request <at> lists.python.cn
> Detail Info:
> http://python.cn/mailman/listinfo/python-chinese
>
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--
With Best Regards
              
          Ralph Wen
          Room 222, Bldg 7, Nanjing Univ.
          Hankou Road, Nanjing, China
          Postal Code: 210089
          E-mail: Ralph.Wen <at> gmail.com
          Tel: +86-025-83596917
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
jessinio smith | 28 Mar 13:19 2007
Picon

Re: python读word

不行的吧

On 3/28/07, Li Chunhui <lich <at> dhc.com.cn> wrote:
大家好,想问一下,怎样用python读windows 下的word文档?

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--
注意身体,身体是革命的本钱!!
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
jessinio smith | 28 Mar 13:30 2007
Picon

Re: 读取excel表格,要看哪些资料?

我是在linux下读取excel文件的,这段代码可否??


On 3/28/07, Wei Jiang <jiejisheng <at> gmail.com> wrote:
这是以前一个报表项目写的库,仅供参考。

import win32com.client
import os
import time

class Excel:
    def __init__(self, filename=None, configuration = None):
 
        self.xApp = win32com.client.Dispatch(' Excel.Application ')
        self.Config = configuration
        
        #start info.  
        #reading configuation file    
        print "Setting standard font: %s" % self.Config['FONT']
        self.xApp.StandardFont = self.Config['FONT']
        
        print "Setting standard size: %s" % str(TextSize)     
        self.xApp.StandardFontSize = TextSize

        #check configuration file       
        if os.path.exists( self.Config['DATAPATH'] ) :
            pass
        else:
            print "Error: The given data path doesn't exist"
            self.close()
        
        # name of report
        if filename:
            self.Filename = filename
            try:
                self.xBook = self.xApp.Workbooks.Open(filename)
            except:
                print "Error: Open file %s failed" % filename
        else:
                           
            self.xBook = self.xApp.Workbooks.Add()
            reportname = self.Config['PROJECT']+ '_R'+ self.Config['VERSION'] + '_' + time.strftime("%Y%m%d") + '_IssueReport'
            self.Filename = os.path.join( self.Config['PATH'], reportname)
            Name = self.Filename + '.xls'
      
          # if the file exists, rename new file as format oldname(number)
            try:
                if os.path.exists ( Name ):
                    number = 2
                    
                    # test new name
                    while 1:                            
                        Name = self.Filename + "(" + str(number) + ").xls"                        
                        if os.path.exists ( Name ):
                            number += 1    
                            continue
                        else :
                            break
                    
                    self.Filename = self.Filename + "(" + str(number) + ").xls"  
                    print "Given name has been used, rename new report to %s" % self.Filename
                else:
                    self.Filename += '.xls'
                    
                print "Report name: %s" % self.Filename   
                self.xBook.SaveAs( self.Filename )
                print "Report file was created"
            except:
                print "Error: creating file failed"

 
    def save(self, newfilename=None):
        
        print "Saving report to %s" % self.Config['PATH']
        if newfilename:
            self.Filename = newfilename
            self.xBook.SaveAs(newfilename)
        else:
            self.xBook.Save()
        print "Report saved"

 
    def close(self):
        self.xBook.Close(SaveChanges=0)
        # close error msg
        del self.xApp

    def show(self):
        print "Show generated report"
        self.xApp.Visible = 1
    
    def delSheet(self, sheet):
        sht = self.xBook.Worksheets(sheet)
        
        try:
            sht.Delete()
            print "sheet %s is deleted" % sheet
        except:
            print "Error: Delete sheet %s failed" % sheet

    def hide(self):
        self.xApp.Visible = 0
 
    # get value from cell
    def getCell(self,sheet, row, col):
        "Get value of one cell"
        sht = self.xBook.Worksheets(sheet)
        return sht.Cells (row, col).Value


    # set value for cell
    def setCell(self, sheet,  row, col, value=None, formula=None):
        
        sht = self.xBook.Worksheets(sheet)
        if formula :
                sht.Cells(row, col).Formula = formula
        else:
                sht.Cells(row, col).Value = value
 
 
    # return tuple
    def getRange(self, sheet, row1, col1, row2, col2):
        "return a 2d array ( i.e. tuple of tuples)"
        sht = self.xBook.Worksheets(sheet)
        return sht.Range(sht.Cells(row1, col1), sht.Cells(row2, col2)).Value

 
 
    # set tuple  for range
    def setRange(self, sheet, topRow, leftCol, data):
        '''
        set range data from a tuple
        '''      
        if type( data ) == types.TupleType:
            
            bottomRow = topRow + len(data) - 1
            rightCol = leftCol + len(data[0]) - 1
            length = len(data)
        else:
            bottomRow = topRow
            rightCol = leftCol
            length = 1
        sht = self.xBook.Worksheets(sheet)
        
        if( length > MaxAccept):    
            times = length/MaxAccept;
            i = 0;    
            # Multiple * MaxAccept data
            while( i < times ):
                
                sht.Range(
                sht.Cells (topRow + i*MaxAccept, leftCol),
                sht.Cells(topRow + (i+1)*MaxAccept - 1, rightCol)
                ).Value = data[i*MaxAccept: (i+1)*MaxAccept]
                
                i += 1
                
            # additional data besides Multiple MaxAccept
            sht.Range(
                sht.Cells(topRow + times * MaxAccept, leftCol),
                sht.Cells(bottomRow, rightCol)
                ).Value = data[times * MaxAccept:]
                
            
        else:
            sht.Range(
                sht.Cells(topRow, leftCol),
                sht.Cells(bottomRow, rightCol)
                ).Value = data
               


    # rename a work sheet
    def setSheetName(self, sheet, name):
        '''
        Rename a sheet
        '''
        sht = self.xBook.Worksheets(sheet)
        
        #logging    
        print "Rename sheet %s to %s" % ( sheet , name )
        sht.Name = name


_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to   python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--
注意身体,身体是革命的本钱!!
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
yi huang | 28 Mar 13:31 2007
Picon

Re: django缓存机制?

我看了下代码,cache_page 不是标准的 decorator ,不能 <at> cache_page 这么用。
另外,python 代码很好看啊,怎么会难看懂呢。大部分代码都是平坦的一层,极少看到深层的抽象。
 
cache_page 在 views/decorators.py line 18 定义。
decorator_from_middleware 函数在 utils/decorators.py ,它返回一个 decorator ,作用是在调用 views 的前后调用相应的 middleware 代码(process_request, process_view, process_response)。middleware 放在 settings 里面是对整个站点起作用,而这个函数实际是让 middleware 只对单个views 起作用。
这里 middleware 就是 middleware/cache.py 的 CacheMiddleware 了,他去使用 django.core.cache 包,这里是真正实现 cache 的地方。
core/cache/__init__.py 根据配置创建 cache 对象。cache 对象的实现就在 backends 包中不同的后端中,这些后端中的 CacheClass 类都实现了同一个协议 (get, set ,delete, get_many, has_key)。
memcached.py 的代码也很少,就是调用 memcache 模块的 api 而已。
 
On 3/28/07, 老生 <liangzhengzhang <at> gmail.com> wrote:
这两天研究django缓存,实在恼火,
 
数据的缓存是没什么问题,即:设置 cache.set("test",data, 60*60*24),读取 cache.get("test"),
 
在views.py的方法前设置缓存如: <at> cache_page(10*60),执行提示 'function' object has no attribute 'method',
 
以上是在WIN上进行测试的,原本以为是setting.py文件中设置的缓存类型不支持,如:CACHE_BACKEND = 'locmem:///c:/tem/,而公司服务器上使用的linux系统,所以今天一整天就在linux环境来进行调试。。。。
 
安装memcached,启动,再进行测试,按照在win上设置 <at> cache_page(10*60)依然出现同样错误提示,如:'function' object has no attribute 'method'
 
换种方式,在urls.py中设置,如(r'^c(?P<cateid>\w+)-b1/$',cache_page(VerifyPostList,10*60)),不会出任何错误提示,这里不知道怎么来测试是否是在取缓存里的东西,所以用种很老土的方式测试,,
 
1、关闭memcached,重启机器,在urls.py中不设置缓存,打印程序执行时间,
 
2、开启memcached,重启机器,在urls.py中设置缓存,打印程序执行时间,
 
如此重复以上几个布置,NND,发现两种布置程序执行的时间都差不多,,,
 
网上查找了好多资料,包括英文 都没发现有django中cache实现原理的资料,看源码的话,想必大家都知道python中的源码实在是难看懂。。。
 
 
 
说了这么多,还是总结以下我的问题及想要了解的东西吧,
 
 
问题一:有兄弟用过 <at> cache_page并成功过的吗?
 
问题二:在views.py中定义的 <at> cache_page与在urls.py中定义的cache_page有什么不同?为何我以上调试测试程序的执行时间都一样?
 
问题三:想实现能找到cache_page中缓存页面的机制,即想在cache中找到缓存页面的key,这样或许有可能我们在后台程序里可以直接获得与修改这个key中的值。。
 
 
 

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to   python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--
http://codeplayer.blogspot.com/
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese
yi huang | 28 Mar 13:36 2007
Picon

Re: django缓存机制?

事实上,如果可以从缓存中取到数据的话,是根本不会调用你的 view 代码的,你想测试缓存是否真的起了作用的话,在 view 里面做手脚就可以,比如 log 个 helloworld,然后多次请求发现确实只有一个 helloworld 。 

On 3/28/07, 老生 <liangzhengzhang <at> gmail.com> wrote:
这两天研究django缓存,实在恼火,
 
数据的缓存是没什么问题,即:设置 cache.set("test",data, 60*60*24),读取 cache.get("test"),
 
在views.py的方法前设置缓存如: <at> cache_page(10*60),执行提示 'function' object has no attribute 'method',
 
以上是在WIN上进行测试的,原本以为是setting.py文件中设置的缓存类型不支持,如:CACHE_BACKEND = 'locmem:///c:/tem/,而公司服务器上使用的linux系统,所以今天一整天就在linux环境来进行调试。。。。
 
安装memcached,启动,再进行测试,按照在win上设置 <at> cache_page(10*60)依然出现同样错误提示,如:'function' object has no attribute 'method'
 
换种方式,在urls.py中设置,如(r'^c(?P<cateid>\w+)-b1/$',cache_page(VerifyPostList,10*60)),不会出任何错误提示,这里不知道怎么来测试是否是在取缓存里的东西,所以用种很老土的方式测试,,
 
1、关闭memcached,重启机器,在urls.py中不设置缓存,打印程序执行时间,
 
2、开启memcached,重启机器,在urls.py中设置缓存,打印程序执行时间,
 
如此重复以上几个布置,NND,发现两种布置程序执行的时间都差不多,,,
 
网上查找了好多资料,包括英文 都没发现有django中cache实现原理的资料,看源码的话,想必大家都知道python中的源码实在是难看懂。。。
 
 
 
说了这么多,还是总结以下我的问题及想要了解的东西吧,
 
 
问题一:有兄弟用过 <at> cache_page并成功过的吗?
 
问题二:在views.py中定义的 <at> cache_page与在urls.py中定义的cache_page有什么不同?为何我以上调试测试程序的执行时间都一样?
 
问题三:想实现能找到cache_page中缓存页面的机制,即想在cache中找到缓存页面的key,这样或许有可能我们在后台程序里可以直接获得与修改这个key中的值。。
 
 
 

_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to   python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese



--
http://codeplayer.blogspot.com/
_______________________________________________
python-chinese
Post: send python-chinese <at> lists.python.cn
Subscribe: send subscribe to python-chinese-request <at> lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request <at> lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese

Gmane