liquid_feedback_frontend
view model/session.lua @ 703:eedb4b514b24
Optical improvements
| author | bsw | 
|---|---|
| date | Tue Jun 26 22:12:25 2012 +0200 (2012-06-26) | 
| parents | 3bfb2fcf7ab9 | 
| children | ea2449916c12 | 
 line source
     1 Session = mondelefant.new_class()
     2 Session.table = 'session'
     3 Session.primary_key = { 'ident' } 
     5 Session:add_reference{
     6   mode          = 'm1',
     7   to            = "Member",
     8   this_key      = 'member_id',
     9   that_key      = 'id',
    10   ref           = 'member',
    11 }
    13 local function random_string()
    14   return multirand.string(
    15     32,
    16     '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    17   )
    18 end
    20 function Session:new()
    21   local session = self.prototype.new(self)  -- super call
    22   session.ident             = random_string()
    23   session.additional_secret = random_string()
    24   session:save() 
    25   return session
    26 end
    28 function Session:by_ident(ident)
    29   local selector = self:new_selector()
    30   selector:add_where{ 'ident = ?', ident }
    31   selector:optional_object_mode()
    32   return selector:exec()
    33 end
