Sunday, December 9, 2012

Wheezy.web and 'Lexer pattern mismatch'

I started making a new website using wheezy.web. I like it so far and the documentation that is there is nice. After using it for a few, I quickly realized that there is a lot of documentation that is lacking or missing. However, all the code for wheezy.web and the rest of wheezy.* is very nice and easy to read and understand.

I did get a strange "Lexer pattern mismatch" when I was trying to use wheezy.template. After narrowing the problem down and figuring out that there wasn't a problem with my templates, I sent Andriy Kornatskyy an email and he figured out the problem.

The online documentation currently has you setup the wheezy.template engine like this:

from wheezy.html.ext.template import WhitespaceExtension
from wheezy.html.ext.template import WidgetExtension
from wheezy.html.utils import format_value
from wheezy.html.utils import html_escape
from wheezy.template.engine import Engine
from wheezy.template.ext.core import CoreExtension
from wheezy.template.loader import FileLoader
from wheezy.web.templates import WheezyTemplate
searchpath = ['content/templates-wheezy']
engine = Engine(
        loader=FileLoader(searchpath),
        extensions=[
            CoreExtension,
            WhitespaceExtension,
            WidgetExtension,
])
engine.global_vars.update({
    'format_value': format_value,
    'h': html_escape,
})
render_template = WheezyTemplate(engine)



It should instead be like this:
engine = Engine(
        loader=FileLoader(searchpath),
        extensions=[
            CoreExtension(),
            WhitespaceExtension(),
            WidgetExtension(),
])

Notice the added parentheses. That fixes the problem.


#python
#wheezy.web
#wheezy.template

New laptop

I just got a new laptop just a few days ago. It's a 17.3 inch ASUS with a Core i7 2.2 GHz, 8GB DDR3, GeForce GT 555M 2GB and 1T 7200 harddrive. It is very nice and large, great for programming. It is more of a mobile desktop though. The battery life when barely using it is around 2 hours. With moderate usages, the battery life is  more like an hourish. But that works for me.

I left windows on it instead of installing linux to make things easier with games and Netflix. But I do have a virtual linux machine via VirtualBox. After looking at several different distributions, I decided on Gentoo. Sure, a from source distribution doesn't sound like a great idea for a virtual machine and compiling does take longer. But I'm used to Gentoo and I can easily have it setup exactly how I want.

#gentoo

Monday, October 25, 2010

More work on Share and Encourage

I've started working on Share and Encourage again. This time I am using flask instead of pylons. I like it a lot more. There is less magic going on and you can use it very simply or organize everything into different modules.

I am working on functionality of the site first this time. Last time, before I restarted work on SaE, I worked on the visuals for the site for days, and still it did not have any basic functionality. I made some good progress last night. I've got a lot of the food section layed out and started on the stores section.

What is Share and Encourage?
It will be a site where you can share pray requests, your bible studies, recipes, food on sale, track your food that you eat, encourage others by letting them know you are praying for them, encourage others to meet their goals of eating healthy among other things.

Why am I making this site? There is no recipe site that has all the feature I want. I want there to be the ability to post a pray request somewhere, without anyone knowing who you are, along with the ability to people to say that they prayed for you without anyone knowing who prayed for the pray request. Knowing that 6 people prayed for your pray request last week would be very encouraging.

Wednesday, March 31, 2010

Unit Tests

I have started using unit tests, PHPUnit specifically, at work finally. I have not created many tests yet, but I will be adding more. Already, I have found a small bug.

I haven't been doing any unit testing at work for several reasons.

  1. When I first started programming, I had no idea that unit testing even existed.
  2. After I found out about unit testing, I liked the idea and wanted to do some. However, I had no idea how to unit test a webpage.
  3. With how busy I was at work, with my TODO list almost always growing, I was not able to start with unit testing even after I figured out how you could unit test webpages.
But that finally changed today. To add a needed feature, I had to do a little reworking of how product counts where handled. After doing that, I needed to test everything out to make sure that it still worked correctly. Since that part of the system is very delicate, I was going to need to spend a few days testing it in every way possible (creating orders, canceling orders, receiving products, etc while making sure to not mess up any real products or orders) That is when I remembered unit testing and then I started using it.

I decided to use PHPUnit for a unit test framework since it looked easy, active, and was easy to information on using it. To get PHPUnit to work with testing our site, I needed to use the '--bootstrap' option. After about an hour of trying to get it to work, I found out that there was a bug in PHPUnit that cause that option to not work. The fix was in version 3.3.x Running Gentoo on my work computer(sooo much better than Windows) only version 3.3.1 was marked as stable. But a quick unmask of the newer version and everything was working good.