On Thu, Aug 03, 2017 at 03:27:16PM +0200, Herby Vojčík wrote:
> Looking at state of the art code:
> GlorpSession >> loginIfError: aBlock
>       | result |
>       result := self accessor loginIfError: aBlock.
>       system platform characterEncoding: accessor encoding.
>       ^result

In the line "result := self accessor loginIfError: aBlock", "self accessor" is
not an instance of DatabaseAccessor, because

  DatabaseAccessor>>loginIfError: aBlock
    self subclassResponsibility

"self accessor" is an instance of PharoDatabaseAccessor, and

  PharoDatabaseAccessor>>loginIfError: aBlock
    self log: 'Login'.
    self databaseDriver: self connectionClass new.
    self
      execute: [
        self databaseDriver connect: currentLogin.
        currentLogin secure
          ifTrue: [ currentLogin discardPassword ]
        ]
      ifError: aBlock.
    self log: 'Login finished'

  PharoDatabaseAccessor>>isLoggedIn
    self databaseDriver ifNil: [^ false].
    ^ self databaseDriver isConnected

Connecting to my instance of Reddit (actually RedditSt20 using SQLite not
PostgreSQL), adding a link and then clicking refresh, Transcript shows:

  Login
  Login finished
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.points DESC LIMIT 20  an OrderedCollection()
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.created DESC LIMIT 20  an 
OrderedCollection()
  Begin Transaction
  INSERT INTO REDDIT_LINKS (url,title,created,points)  VALUES (?,?,?,?)  
    an Array('http://planet.smalltalk.org' 'Planet Smalltalk' 
2017-08-04T22:25:14.558667+08:00 0)
  SELECT last_insert_rowid()
  (0.0 s)
  Commit Transaction
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.points DESC LIMIT 20  an OrderedCollection()
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.created DESC LIMIT 20  an 
OrderedCollection()

Login happened once. Clicking "New Session":

  Logout
  Logout finished
  Login
  Login finished
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.points DESC LIMIT 20  an OrderedCollection()
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.created DESC LIMIT 20  an 
OrderedCollection()

Clicking "Refresh" in the application:

  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.points DESC LIMIT 20  an OrderedCollection()
  SELECT t1.id, t1.url, t1.title, t1.created, t1.points
   FROM REDDIT_LINKS t1 ORDER BY t1.created DESC LIMIT 20  an 
OrderedCollection()


Pierce


Reply via email to