temp vars in dal.py (fixed error)

This commit is contained in:
mdipierro
2012-08-28 19:07:26 -05:00
parent e821955c97
commit 5af9fe0a3e
4 changed files with 63 additions and 47 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.1 (2012-08-28 18:52:20) rc4 Version 2.00.1 (2012-08-28 19:07:21) rc4
+14 -1
View File
@@ -39,7 +39,6 @@
'customize me!': 'Personalizzami!', 'customize me!': 'Personalizzami!',
'data uploaded': 'dati caricati', 'data uploaded': 'dati caricati',
'Database': 'Database', 'Database': 'Database',
'Database': 'Database',
'Database %s select': 'Database %s select', 'Database %s select': 'Database %s select',
'db': 'db', 'db': 'db',
'DB Model': 'Modello di DB', 'DB Model': 'Modello di DB',
@@ -68,7 +67,9 @@
'First name': 'Nome', 'First name': 'Nome',
'Forms and Validators': 'Forms and Validators', 'Forms and Validators': 'Forms and Validators',
'Free Applications': 'Free Applications', 'Free Applications': 'Free Applications',
'Group %(group_id)s created': 'Group %(group_id)s created',
'Group ID': 'ID Gruppo', 'Group ID': 'ID Gruppo',
'Group uniquely assigned to user %(id)s': 'Group uniquely assigned to user %(id)s',
'Groups': 'Groups', 'Groups': 'Groups',
'hello': 'hello', 'hello': 'hello',
'hello world': 'salve mondo', 'hello world': 'salve mondo',
@@ -84,6 +85,7 @@
'Internal State': 'Stato interno', 'Internal State': 'Stato interno',
'Introduction': 'Introduction', 'Introduction': 'Introduction',
'Invalid email': 'Email non valida', 'Invalid email': 'Email non valida',
'Invalid login': 'Invalid login',
'Invalid Query': 'Richiesta (query) non valida', 'Invalid Query': 'Richiesta (query) non valida',
'invalid request': 'richiesta non valida', 'invalid request': 'richiesta non valida',
'Is Active': 'Is Active', 'Is Active': 'Is Active',
@@ -92,9 +94,12 @@
'Layout Plugins': 'Layout Plugins', 'Layout Plugins': 'Layout Plugins',
'Layouts': 'Layouts', 'Layouts': 'Layouts',
'Live Chat': 'Live Chat', 'Live Chat': 'Live Chat',
'Logged in': 'Logged in',
'login': 'accesso', 'login': 'accesso',
'Login': 'Login', 'Login': 'Login',
'logout': 'uscita', 'logout': 'uscita',
'Logout': 'Logout',
'Lost Password': 'Lost Password',
'Lost password?': 'Lost password?', 'Lost password?': 'Lost password?',
'lost password?': 'dimenticato la password?', 'lost password?': 'dimenticato la password?',
'Main Menu': 'Menu principale', 'Main Menu': 'Menu principale',
@@ -117,10 +122,13 @@
'Other Recipes': 'Other Recipes', 'Other Recipes': 'Other Recipes',
'Overview': 'Overview', 'Overview': 'Overview',
'Password': 'Password', 'Password': 'Password',
"Password fields don't match": "Password fields don't match",
'please input your password again': 'please input your password again',
'Plugins': 'Plugins', 'Plugins': 'Plugins',
'Powered by': 'Powered by', 'Powered by': 'Powered by',
'Preface': 'Preface', 'Preface': 'Preface',
'previous 100 rows': '100 righe precedenti', 'previous 100 rows': '100 righe precedenti',
'Profile': 'Profile',
'Python': 'Python', 'Python': 'Python',
'Query:': 'Richiesta (query):', 'Query:': 'Richiesta (query):',
'Quick Examples': 'Quick Examples', 'Quick Examples': 'Quick Examples',
@@ -135,6 +143,8 @@
'register': 'registrazione', 'register': 'registrazione',
'Registration identifier': 'Registration identifier', 'Registration identifier': 'Registration identifier',
'Registration key': 'Chiave di Registazione', 'Registration key': 'Chiave di Registazione',
'Registration successful': 'Registration successful',
'Remember me (for 30 days)': 'Remember me (for 30 days)',
'Reset Password key': 'Resetta chiave Password ', 'Reset Password key': 'Resetta chiave Password ',
'Role': 'Ruolo', 'Role': 'Ruolo',
'Rows in Table': 'Righe nella tabella', 'Rows in Table': 'Righe nella tabella',
@@ -161,7 +171,10 @@
'Update': 'Update', 'Update': 'Update',
'Update:': 'Aggiorna:', 'Update:': 'Aggiorna:',
'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.': 'Per costruire richieste (query) più complesse si usano (...)&(...) come "e" (AND), (...)|(...) come "o" (OR), e ~(...) come negazione (NOT).', 'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.': 'Per costruire richieste (query) più complesse si usano (...)&(...) come "e" (AND), (...)|(...) come "o" (OR), e ~(...) come negazione (NOT).',
'User %(id)s Logged-in': 'User %(id)s Logged-in',
'User %(id)s Registered': 'User %(id)s Registered',
'User ID': 'ID Utente', 'User ID': 'ID Utente',
'Verify Password': 'Verify Password',
'Videos': 'Videos', 'Videos': 'Videos',
'View': 'Vista', 'View': 'Vista',
'Welcome': 'Welcome', 'Welcome': 'Welcome',
+2 -1
View File
@@ -7089,7 +7089,8 @@ def index():
return self.__getattr__(str(key)) return self.__getattr__(str(key))
def __getattr__(self, key): def __getattr__(self, key):
if ogetattr(self,'_lazy_tables') and not key in ogetattr(self,'_LAZY_TABLES'): if ogetattr(self,'_lazy_tables') and \
key in ogetattr(self,'_LAZY_TABLES'):
tablename, fields, args = self._LAZY_TABLES.pop(key) tablename, fields, args = self._LAZY_TABLES.pop(key)
return self.lazy_define_table(tablename,*fields,**args) return self.lazy_define_table(tablename,*fields,**args)
return ogetattr(self, key) return ogetattr(self, key)
+46 -44
View File
@@ -298,14 +298,15 @@ class Response(Storage):
default to the last request argument otherwise) default to the last request argument otherwise)
""" """
headers = self.headers
# for attachment settings and backward compatibility # for attachment settings and backward compatibility
keys = [item.lower() for item in self.headers] keys = [item.lower() for item in headers]
if attachment: if attachment:
if filename is None: if filename is None:
attname = "" attname = ""
else: else:
attname = filename attname = filename
self.headers["Content-Disposition"] = \ headers["Content-Disposition"] = \
"attachment;filename=%s" % attname "attachment;filename=%s" % attname
if not request: if not request:
@@ -314,30 +315,31 @@ class Response(Storage):
stream_file_or_304_or_206(stream, stream_file_or_304_or_206(stream,
chunk_size=chunk_size, chunk_size=chunk_size,
request=request, request=request,
headers=self.headers) headers=headers)
# ## the following is for backward compatibility # ## the following is for backward compatibility
if hasattr(stream, 'name'): if hasattr(stream, 'name'):
filename = stream.name filename = stream.name
if filename and not 'content-type' in keys: if filename and not 'content-type' in keys:
self.headers['Content-Type'] = contenttype(filename) headers['Content-Type'] = contenttype(filename)
if filename and not 'content-length' in keys: if filename and not 'content-length' in keys:
try: try:
self.headers['Content-Length'] = \ headers['Content-Length'] = \
os.path.getsize(filename) os.path.getsize(filename)
except OSError: except OSError:
pass pass
env = request.env
# Internet Explorer < 9.0 will not allow downloads over SSL unless caching is enabled # Internet Explorer < 9.0 will not allow downloads over SSL unless caching is enabled
if request.is_https and isinstance(request.env.http_user_agent,str) and \ if request.is_https and isinstance(env.http_user_agent,str) and \
not re.search(r'Opera', request.env.http_user_agent) and \ not re.search(r'Opera', env.http_user_agent) and \
re.search(r'MSIE [5-8][^0-9]', request.env.http_user_agent): re.search(r'MSIE [5-8][^0-9]', env.http_user_agent):
self.headers['Pragma'] = 'cache' headers['Pragma'] = 'cache'
self.headers['Cache-Control'] = 'private' headers['Cache-Control'] = 'private'
if request and request.env.web2py_use_wsgi_file_wrapper: if request and env.web2py_use_wsgi_file_wrapper:
wrapped = request.env.wsgi_file_wrapper(stream, chunk_size) wrapped = env.wsgi_file_wrapper(stream, chunk_size)
else: else:
wrapped = streamer(stream, chunk_size=chunk_size) wrapped = streamer(stream, chunk_size=chunk_size)
return wrapped return wrapped
@@ -365,11 +367,12 @@ class Response(Storage):
(filename, stream) = field.retrieve(name) (filename, stream) = field.retrieve(name)
except IOError: except IOError:
raise HTTP(404) raise HTTP(404)
self.headers['Content-Type'] = contenttype(name) headers['Content-Type'] = contenttype(name)
if attachment: if attachment:
self.headers['Content-Disposition'] = \ headers['Content-Disposition'] = \
"attachment; filename=%s" % filename 'attachment; filename=%s' % filename
return self.stream(stream, chunk_size = chunk_size, request=request) return self.stream(stream, chunk_size = chunk_size,
request=request)
def json(self, data, default=None): def json(self, data, default=None):
return json(data, default = default or custom_json) return json(data, default = default or custom_json)
@@ -462,14 +465,15 @@ class Session(Storage):
response.session_id_name = 'session_id_%s' % masterapp.lower() response.session_id_name = 'session_id_%s' % masterapp.lower()
# Load session data from cookie # Load session data from cookie
cookies = request.cookies
if cookie_key: if cookie_key:
response.session_cookie_key = cookie_key response.session_cookie_key = cookie_key
response.session_cookie_key2 = hashlib.md5(cookie_key).digest() response.session_cookie_key2 = hashlib.md5(cookie_key).digest()
cookie_name = request.application.lower()+'_session_data' cookie_name = masterapp.lower()+'_session_data'
response.session_cookie_name = cookie_name response.session_cookie_name = cookie_name
if cookie_name in request.cookies: if cookie_name in cookies:
cookie_value = request.cookies[cookie_name].value cookie_value = cookies[cookie_name].value
cookie_parts = cookie_value.split(":") cookie_parts = cookie_value.split(":")
enc = cookie_parts[2] enc = cookie_parts[2]
cipher = AES.new(cookie_key) cipher = AES.new(cookie_key)
@@ -487,9 +491,9 @@ class Session(Storage):
return return
response.session_new = False response.session_new = False
client = request.client and request.client.replace(':', '.') client = request.client and request.client.replace(':', '.')
if response.session_id_name in request.cookies: if response.session_id_name in cookies:
response.session_id = \ response.session_id = \
request.cookies[response.session_id_name].value cookies[response.session_id_name].value
if regex_session_id.match(response.session_id): if regex_session_id.match(response.session_id):
response.session_filename = \ response.session_filename = \
os.path.join(up(request.folder), masterapp, os.path.join(up(request.folder), masterapp,
@@ -542,38 +546,35 @@ class Session(Storage):
table_migrate = False table_migrate = False
tname = tablename + '_' + masterapp tname = tablename + '_' + masterapp
table = db.get(tname, None) table = db.get(tname, None)
Field = db.Field
if table is None: if table is None:
table = db.define_table( db.define_table(
tname, tname,
db.Field('locked', 'boolean', default=False), Field('locked', 'boolean', default=False),
db.Field('client_ip', length=64), Field('client_ip', length=64),
db.Field('created_datetime', 'datetime', Field('created_datetime', 'datetime',
default=request.now), default=request.now),
db.Field('modified_datetime', 'datetime'), Field('modified_datetime', 'datetime'),
db.Field('unique_key', length=64), Field('unique_key', length=64),
db.Field('session_data', 'blob'), Field('session_data', 'blob'),
migrate=table_migrate, migrate=table_migrate,
) )
table = db[tname] # to allow for lazy table
try: try:
# Get session data out of the database # Get session data out of the database
# Key comes from the cookie
# Key comes from the cookie key = cookies[response.session_id_name].value
key = request.cookies[response.session_id_name].value
(record_id, unique_key) = key.split(':') (record_id, unique_key) = key.split(':')
if record_id == '0': if record_id == '0':
raise Exception, 'record_id == 0' raise Exception, 'record_id == 0'
# Select from database. # Select from database
rows = db(table.id == record_id).select() rows = db(table.id == record_id).select()
# Make sure the session data exists in the database
# Make sure the session data exists in the database
if len(rows) == 0 or rows[0].unique_key != unique_key: if len(rows) == 0 or rows[0].unique_key != unique_key:
raise Exception, 'No record' raise Exception, 'No record'
# rows[0].update_record(locked=True)
# rows[0].update_record(locked=True) # Unpickle the data
# Unpickle the data
session_data = cPickle.loads(rows[0].session_data) session_data = cPickle.loads(rows[0].session_data)
self.update(session_data) self.update(session_data)
except Exception: except Exception:
@@ -583,8 +584,9 @@ class Session(Storage):
response._dbtable_and_field = \ response._dbtable_and_field = \
(response.session_id_name, table, record_id, unique_key) (response.session_id_name, table, record_id, unique_key)
response.session_id = '%s:%s' % (record_id, unique_key) response.session_id = '%s:%s' % (record_id, unique_key)
response.cookies[response.session_id_name] = response.session_id rcookies = response.cookies
response.cookies[response.session_id_name]['path'] = '/' rcookies[response.session_id_name] = response.session_id
rcookies[response.session_id_name]['path'] = '/'
self.__hash = hashlib.md5(str(self)).digest() self.__hash = hashlib.md5(str(self)).digest()
if self.flash: if self.flash:
(response.flash, self.flash) = (self.flash, None) (response.flash, self.flash) = (self.flash, None)