source: publico/PloneImapClient/trunk/Cache.py @ 2484

Última Alteração nesse arquivo desde 2484 foi 2484, incluída por johnnysouza, 14 anos atrás

Atualizacao do modelo

File size: 3.7 KB
Linha 
1# File: Cache.py
2#
3# Copyright (c) 2006 by Interlegis
4# Generator: ArchGenXML Version 1.4.0-RC2 svn/development
5#            http://plone.org/products/archgenxml
6#
7# GNU General Public Licence (GPL)
8#
9# This program is free software; you can redistribute it and/or modify it under
10# the terms of the GNU General Public License as published by the Free Software
11# Foundation; either version 2 of the License, or (at your option) any later
12# version.
13# This program is distributed in the hope that it will be useful, but WITHOUT
14# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
16# details.
17# You should have received a copy of the GNU General Public License along with
18# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19# Place, Suite 330, Boston, MA  02111-1307  USA
20#
21__author__  = '''STC Interlegis <stc@interlegis.gov.br>'''
22__docformat__ = 'plaintext'
23
24
25##code-section module-header #fill in your manual code here
26##/code-section module-header
27
28
29
30
31class Cache:
32    ''' <p>cache das informacao do email de cada usuario</p>'''
33    __implements__ = ()
34
35    ##code-section class-header_Cache #fill in your manual code here
36    ##/code-section class-header_Cache
37
38
39    def __init__(self,*args,**kwargs):
40        self._init_attributes(*args,**kwargs)
41
42
43    def _init_attributes(self,*args,**kwargs):
44        #attributes
45        self._folders=None
46        self._headers=None
47        self._folderAtual=None
48        self._tool=None
49        self.user=None
50
51        # automatically set attributes where mutators exist
52        for key in kwargs.keys():
53            # camel case: variable -> setVariable
54            mutatorName = 'set'+key[0].upper()+key[1:]
55            mutator = getattr(self, mutatorName)
56            if mutator is not None and callable(mutator):
57                mutator(kwargs[key])
58
59
60    def maskAsRead(self,folder,index):
61        pass
62
63
64    def _atualizar_headers(self,folder):
65        pass
66
67
68    def atualizar(self,):
69        c = self._tool.getConecao(self._user)
70        typ, lista = c.list()
71        folders = []
72        for i in lista:
73            if i.find(r'\Noselect') < 0:
74                if i[-1] == '"':
75                    name = i.split('"')[-2]
76                else:
77                    name = i.split(' ')[-1]
78                #
79                #
80                # PROBLEMA DE PERFORMANCE NO COMANDO STATUS
81                #
82                #
83                typ, [nmsg] = c.status(name,'(MESSAGES UNSEEN)')
84                # separa o que esta entre parenteses
85                nmsg = nmsg.split('(')[-1].split(')')[0].split(' ')
86                nmsg[1] = int(nmsg[1])
87                nmsg[3] = int(nmsg[3])
88                # o numero de nao lidas deve ser menor ou igual ao total
89                if nmsg[1] < nmsg[3]:
90                    nlidas = nmsg[1]
91                    total = nmsg[3]
92                else:
93                    total = nmsg[1]
94                    nlidas = nmsg[3]
95        self._atualizar_headers('INBOX')
96        c.logout()
97
98
99
100
101    def set_headers(self,value):
102        self._headers=value
103
104
105    def set_folderAtual(self,value):
106        self._folderAtual=value
107
108
109    def get_headers(self):
110        return self._headers
111
112
113    def get_tool(self):
114        return self._tool
115
116
117    def get_folders(self):
118        return self._folders
119
120
121    def getUser(self):
122        return self.user
123
124
125    def get_folderAtual(self):
126        return self._folderAtual
127
128
129    def setUser(self,value):
130        self.user=value
131
132
133    def set_folders(self,value):
134        self._folders=value
135
136
137    def set_tool(self,value):
138        self._tool=value
139
140
141##code-section module-footer #fill in your manual code here
142##/code-section module-footer
143
144
145
Note: Veja TracBrowser para ajuda no uso do navegador do trac.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.