samadhiweb

smalltalk programming for the web



Seaside and Pharo 5

21 May 2017

I just tried loading Seaside into the latest Pharo 6 pre-release image from the Catalog Browser. It loads cleanly. However, the Seaside control panel doesn't start because it uses NewListModel which does not exist in this image:

WAPharoServerAdapterSpecBrowser>>#initializeWidgets

  self instantiateModels: #(
    listModel NewListModel "<== Exists In Pharo 5, not in Pharo 6"
    textModel TextModel
    toolbarModel WAServerAdapterToolbar).

Ok, how about Pharo 5? Using Pharo 50772, which is currently the latest Pharo 5 image, I loaded Seaside 3.1.5 programmatically after visually inspecting ConfigurationOfSeaside3:

Gofer it 
  smalltalkhubUser: 'Seaside' project: 'Seaside31';
  package: 'ConfigurationOfSeaside3';
  load.
(#ConfigurationOfSeaside3 asClass project version: '3.1.5') load.

The load sequence includes messages to String>>#subStrings: which is deprecated. The senders are GRStringTest>>#testSubStrings, JQAjax>>#callback:passengers:, WAAdmin class>>#register:at:in: and WAAdmin class>>#unregister:in:.

Otherwise Seaside 3.1.5 loads cleanly. Test Runner reports 1173 run, 1171 passes and 2 expected failures.

Proof of Concept: FileTree and Fossil

28 February 2017

While putting up PasswordCrypt on Github, I was working with its local FileTree repository. I found the workflow cumbersome - committing in Pharo causes untracked files and so on as seen by Git, which had to be resolved by hand, followed by 'git commit' and 'git push'. I know that tools like GitFileTree and Iceberg are meant to smoothen the workflow. I also know that I don't know Git well at all.

OTOH, I use multiple computers - a main Linux/Windows workstation, a Mac, and a small laptop for tinkering on the go - and keeping all my mcz files in sync on these computers is getting to be a chore.

I am a fan of Fossil. In addition to being a DVCS a la Git, Fossil comes with a wiki, ticketing system, simple HTTP-based networking to sync repositories, and other good stuff. This blog's content is managed using Fossil.

However, using Fossil in place of Git to manage FileTree repositories at the directories/files level still requires the 2-step workflow: commit in Pharo, fix up the changes with Fossil, commit in Fossil.

So I wrote a simple integration of FileTree with Fossil.

At the operating system command prompt, init a new Fossil project:

os% mkdir ~/repo
os% cd ~/repo
os% fossil init myproject.fossil
project-id: 3c05c3016eeabf8e87816ee218c6a86d3c87b950
server-id:  ff42bc86dba1a26b1d94b64685f7c09d02581617
admin-user: laptop-user (initial password is "1fe2ff")

Open the repository:

os% mkdir ~/myproject
os% cd ~/myproject
os% fossil open ~/repo/myproject.fossil

In a fresh Pharo 6 image - I used v60411 - install FossilFileTree:

Metacello new 
  baseline: 'FossilFileTree'; 
  repository: 'github://PierceNg/FossilFileTree'; 
  load.

Write code in Pharo. Open Monticello Browser. Add a "fossilfiletree" repository, using ~/myproject as the directory. Save to said repository from within Monticello Browser. Done.

To check what Fossil got, run 'fossil status' in ~/myproject. The last line 'comment: ...' contains the in-Pharo commit message.

And now I get to use Fossil to keep my FileTree repositories in sync among my computers.

Notes:

  • I basically copied GitFileTree's use of OSSubprocess to call the Fossil executable.
  • Tested on Linux with recent Pharo 6 only. I tried to install on a Pharo 5 image, but the installation hung somewhere.
  • The above is all this thing does. For all other Fossil-related operations - clone, sync/push/pull - use Fossil.
  • Not written any test.

Logging libraries for Pharo 5

19 February 2017

Below are the logging libraries that I've found for Pharo/Squeak:

  • Log4s
  • Nagare
  • OsmoSyslog
  • Syslog
  • SystemLogger
  • Toothpick

Log4s for Pharo is a port of the VA Smalltalk port of the popular Java logging framework Log4j. I installed it from Pharo 5's catalog browser. 206 of 207 tests passed, with 1 failure. None of the classes is commented, although being a port of Log4j, the Java documentation should work as reference.

Nagare is a "flexible logger which connects to Fluentd." It was written to run on VisualWorks, Squeak and Pharo. I installed it from the catalog browser. None of the classes is commented. No test suite. Documentation remains on the Google Code project wiki.

OsmoSyslog is a "log backend/target to use system syslog." AGPLv3+. I stopped there.

Syslog is an RFC5452 Syslog UDP client. I installed it using a Gofer snippet. It loads OSProcess. Every class has a class comment. Test suite has four tests. Because I have OSSubprocess in the same image I did not attempt to run the tests.

SystemLogger "is an easy to use, very lightweight, and highly configurable object logging framework." It failed to install from the catalog browser but loaded successfully using a Gofer snippet. Every class has a class comment. 17 of 19 tests passed, with 2 failures.

Toothpick is a port to Pharo of the Smalltalk library written to run on Dolphin, Squeak, VisualAge and VisualWorks. Documentation on the original site looks good. 16 of 19 tests passed, with 1 failure and 2 errors.

SHA256/512 Password Hashing for Pharo 5

18 February 2017

I've updated my SHA256/512 password hashing library to Pharo 5's FFI and moved it from SS3 to GH.

In the GH repo, C source files are in the src-c directory. Compile with the Makefile there. Move the .so or .dylib file to where the VM can find it.

To load the Smalltalk code, in a Pharo playground:

Metacello new 
  baseline: 'PasswordCrypt'; 
  repository: 'github://PierceNg/PasswordCrypt/src-st'; 
  load.

Run the tests in TestRunner. Provided the Pharo VM can find the shared library, all 12 tests should pass.

This version adds an authentication database that uses in-image persistence, accessed programmatically via the PCAuthenticator uniqueInstance, and a very simple user interface invoked thusly:

PCAuthenticatorUI new openWithSpec

Currently PCAuthenticator hardcodes to SHA256. It should be straightforward to make the hashing algorithm pluggable, including from other shared libraries. Hosting on GH makes it easier for forks and PRs.