A Starter for the Rice and Raisin

500D_2057

Just a quick update on the rice and raisin.  I followed the recipe and realised it wanted a starter.  A starter?  A quick flick through the book said I should have set this up the day before too.  Rather than exhibit patience, I knocked one up with yeast, nutrient and sugar, waited until it was frothing, then bunged it in with some warm water.

I mucked up again, because I had assumed that I could just top up to 1 gallon.  But as I sloshed in the water I realised I was already pretty much there because of the displacement from the rice and raisins.  <sigh>.

So I judged it by eye and measured the specific gravity, which was an OG of 1090.  That looked about right so I didn’t fiddle any more and just left it to ferment.

 

Californian Connoisseur following the plan…

500D_1982
Just a quick note on the Pinot Chardonnay.  It is day 14 today and by day 20 it should have completely speed bubbling. It has slowed down to a virtual stop already, and the temperature has also fallen to 18 degrees. I suspect that this is partly because it is cold here but also because the year is less active. I’ve tweaked up the brew belt anyway. It is now on about 80% of the time.

I know it is chemistry, and I’m following the instructions carefully, but it is still magical to see it all working out.

Rice and Raisin Wine

Stirring up
Stirring up

Now I have more demijohns, it seems time to get something else going.  For once, I used a recipe from an old wine making book that my wife found from our first (unsuccessful) foray in to wine making.

I’d not really looked at the recipe before starting and was a little surprised to find it specified short grain pudding rice.  We didn’t have enough of that kicking around but a quick google found that basmati rice should do just as well.  I followed the initial instructions easily enough with the only problem that I was too cackhanded to peel the orange thinly without pith.  I used a microplane instead.

The mixture (“must”?) is now resting for a day with a Campden tablet in situ.  I think that the 24 hour rest gives the time for the sulphites from the Campen tablet to escape, maybe also for the rice to soften a bit?

Tomorrow I will make the yeast starter, find out the OG and set it on its merry way.

CakePHP eureka moments

It is a very  steep learning curve, and I keep forgetting what I learn, so just going to keep a list.

  1. To make a link to ‘id’ on a .ctp page link to something more useful change the column name thus:
    echo $this->Html->link($powerpoint['User']['id'], array('controller' => 'users', 'action' => 'view', $powerpoint['User']['id'])); 
    
    //becomes
    
    echo $this->Html->link($powerpoint['User']['username'], array('controller' => 'users', 'action' => 'view', $powerpoint['User']['id']));

    (The query is doing a join automatically in the background)

  2. To make a droplist show a useful thing like the name rather than the key, you need to go in to the XxxxxxController and change the function thus:
    $users = $this->Powerpoint->User->find('list');
    
    //becomes
    
    $users = $this->Powerpoint->User->find('list',array('fields' => array('User.id', 'User.username')));

    I guess it then used the two fields as given.  If you add a third field it is used as a label in the option.  Not sure how to concatenate the columns if you want “Firstname Lastname” in the droplist.

  3. The Model reflects the database. I knew that but recording it here, as I actually used it.
  4. If you have a table that is joined through another table (belongsto > belongsto) then you can make it appear thus in the Controller:
    		$users = $this->Question->Powerpoint->find('list', array(
    				"fields" => array('Powerpoint.user_id', 'Users.username'),
    				"joins" => array(
    					array(
    						"table" => "Users",
    						"type" => "LEFT",
    						"conditions" => array(
    							"Powerpoint.user_id = users.id"
    						)
    					)
    				)
    			));

     

CakePHP ACL with bcrypt/blowfish

I have been playing around with cakePHP, trying to get the authentication to play nicely with bcrypt.  bcrypt (blowfish crypt?) is a way of encrypting data which includes its own random salt in the hash.  So you only need one field for the password but it is pretty secure.

After a lot of pain, it turns out that moving from the working basic ACL security (set up using the tutorial) to bcrypt is pretty easy.  Two files to change!  But it took me hours to work out because of silly errors like not having the password field in the database long enough for the hash (they appear to be 250 characters long).

I suspect I don’t need the ‘username’ => ‘username’ etc. but after a long effort to get it working I don’t really want to break it again.

<?php
/**
 * Application level Controller
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

App::uses('Controller', 'Controller');

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package		app.Controller
 * @link		http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
 */
class AppController extends Controller {

    public $components = array(
        'Acl',
        'Auth' => array(
            'authorize' => array(
                'Actions' => array('actionPath' => 'controllers')
            ),
			'authenticate' => array(
				'Blowfish' => array(
					'fields' => array(
						'username' => 'username',
						'password' => 'password'
					),
					'userModel' => 'User',
					'scope' => array()
				)
			)
        ),
        'Session'
    );

    public $helpers = array('Html', 'Form', 'Session');

    public function beforeFilter() {

		// Use bcrypt for hashes
		Security::setHash('blowfish');

        //Configure AuthComponent
        $this->Auth->loginAction = array(
          'controller' => 'users',
          'action' => 'login'
        );
        $this->Auth->logoutRedirect = array(
          'controller' => 'users',
          'action' => 'login'
        );
        $this->Auth->loginRedirect = array(
          'controller' => 'posts',
          'action' => 'add'
        );

		$this->Auth->allow('display');
    }
}

And change the beforeSave function in Model/User.php

	// for acl with blowfish/bcrypt
    public function beforeSave($options = array()) {

		// hash the password
        $this->data['User']['password'] = Security::hash($this->data['User']['password']);	

        return true;

    }

Of course, enabling this breaks the working logins and you have to edit them to get the new hashes.  You’ll be locked out if you don’t put $this->Auth->allow(); in the beforeFilter() function of the UsersController.php whilst you do it.