webmcp

view demo-app/model/session.lua @ 11:d76a8857ba62

Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link

Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"

Documentation for added functions is not yet complete.
author jbe/bsw
date Fri Feb 12 18:40:22 2010 +0100 (2010-02-12)
parents 9fdfb27f8e67
children
line source
1 Session = mondelefant.new_class()
2 Session.table = 'session'
3 Session.primary_key = { "ident" }
5 Session:add_reference{
6 mode = 'm1', -- many (m) sessions refer to one (1) user
7 to = "User", -- name of referenced model (quoting avoids auto-loading here)
8 this_key = 'user_id', -- own key in session table
9 that_key = 'id', -- other key in user table
10 ref = 'user', -- name of reference
11 back_ref = nil, -- not used for m1 relation!
12 default_order = nil -- not used for m1 relation!
13 }
15 local function random_string()
16 return multirand.string(
17 32,
18 '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
19 )
20 end
22 function Session:new()
23 local session = self.prototype.new(self) -- super call
24 session.ident = random_string()
25 session.csrf_secret = random_string()
26 session:save()
27 return session
28 end
30 function Session:by_ident(ident)
31 local selector = self:new_selector()
32 selector:add_where{ 'ident = ?', ident }
33 selector:optional_object_mode()
34 return selector:exec()
35 end

Impressum / About Us