I laugh whenever I see a bass with batteries wrapped in foam.
It's a completely half assed way to do it, and I'm shocked that so many players will accept half assed solutions to anything on their instruments.
Batteries should be secured to the bass, either in the control cavity with clips, or elsewhere with a dedicated battery compartment.
I have three of those clips (The kind that mounts the battery flipped around by 90 degrees though, they take up less space than the one in that picture.) in my Jazz bass for my 27V OBP-1, and they work great.
Be careful about the length of the mounting screws though, if they don't pierce through the top of the bass, they can still leave little dimples in the finish from the wood expanding around the screw.
I damaged my finish slightly this way.
I'll have to post the pictures later, when I'm not on my iPhone...