Saturday, February 27, 2010

Umbraco… Not ready for the limelight yet?

I’ve been trying to use Umbraco CMS with my web host (See yesterday’s rant for a little more on that), but it seems that every version prior to 4.1 won’t run under “Medium Trust” (Something my web host seems to need). Thus I have downloaded the 4.1b2 version of Umbraco, and what do I find?

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Request failed.

Source Error:

Line 145:            <providers>
Line 146:                <clear />
Line 147:                <add name="UmbracoRoleProvider" type="umbraco.providers.members.UmbracoRoleProvider" />
Line 148:            </providers>
Line 149:        </roleManager>

Looking through the bugtracker, I find the answer that “This'll be because I haven't brought my replacements for umbraco.providers into the 4.1 trunk yet. Will do later on today.” That was posted on the 18th, and the issue was marked as “Fixed”, yet going through the changelogs there doesn’t appear to be any such fix applied as of yet.

This kind of thing is infuriating, and makes the past 3 months spent learning Umbraco’s templating and design system a complete waste. At the moment, I can’t use this system, as powerful and nice as it is, which means I’ve wasted valuable time. So I’m on the lookout for another open-source (or at least free-to-use) CMS system that supports discussion fora, is reasonably simple to use on the back end, and works under Medium Trust .net v2 (Perhaps v3.5, but given that 3.5 runs on-top of v2, it’s difficult to see what version is actually installed). I’d also prefer C#, but that’s not really a necessity.

Anyone have any suggestions?

1&1 Internet – Great pricing, not so hot .Net support, Atrocious billing…

Well, here we go with another rant. It’s been a little too long since the last one of these, so here we go.

I have an account with 1&1 internet, to do Microsoft Web Hosting. The price was great for what you get (I mean, really, check it out for yourself!) but for billing… I guess it would be easier if we had a credit card, but the banks seem to disagree with us on that, so we used (or at least tried to use) a Visa Gift Card instead.

They have difficulty accepting them, it seems. And while you can pay with PayPal, it uses PayPal’s “Pre-Authorised Debit” system. Great, except for two things. One, it needs a credit card associated with the account, and two, it doesn’t work at all outside the US. Not that you can see that. You can go (from their merchant link to set it up) and set the authorisation, choose the maximum amount they can take, and as far as you can see everything is AOK. But if you sign in to your PayPal account (Using your country’s portal), there’s no sign of any pre-authorised options, you can’t adjust them or anything. ‘Cause it’s US only.

So now I have paid them using a Swift EFT, a direct electronic money transfer from my bank to them. I called them to confirm they’ve received it, and they claim so, but I’m still getting automated messages on my account details page saying it’s overdue. *sigh*. I’ll call them again on Monday and see what they say.

The other issue is that they run their .net apps at Medium trust, and with little sign of what version and extensions are installed.

The “Medium Trust” lead me to not be able to use Umbraco 4.0b (Which I was developing against on my local staging site). I’m hoping they’re running .net 3.5, ‘cause then I can use the newly-released Umbraco 4.1b (Which does work against Medium trust, but Requires .net 3.5). If they’re not running .net 3.5, I’m going to be screwed here, quite honestly. At that point it starts looking more cost and effort effective to buy a basic box on Amazon EC2 and use that to host, though the bandwidth costs there would be the main expense.

Still, live and learn, huh?

Sunday, November 22, 2009

Sasktel’s service is great, it’s a shame their hardware isn’t so…

Guess what? It’s another rant! (I seem to be very good at these, for some reason).

Okay, so I’m a Sasktel subscriber here in Regina – That means I use their ADSL2e service for internet and TV, as they have a nifty IPTV network. The IPTV part I love, as it works a dream with my MythTV DVR, but the Router they provide (And that you HAVE to use – because of the way it handles DHCP assignments for the set-top boxes, and talking to the DSLAM, you have no other option), a 2-Wire unit customised (slightly) for them, is very poor. It doesn’t support UPNP for port allocation, not that it’s THAT much of an issue – If you have more than around 100 ports forwarded, it slows access to a crawl. The internal DHCP server and DNS forwarder also slow down within hours of rebooting, and stop working after a few days of uptime. If you change your network settings (or, indeed, the handed-out settings) to use the upstream DNS servers, things work fine, unless (of course) you need to connect a “new” machine to the network. Then, as the DHCP server is timing out every time, you can’t.

I have a second router (What I was using before I signed up for Sasktel) that I am more than pleased with – It’s a Belkin router that’s been hacked to run DD-WRT. That makes for a great router (With working UPNP and QoS), and it’s fast enough, and has enough RAM that there are rarely issues with internal servers dying. It can even make “Hotspot” systems with a little setting up, though I have no need of that functionality. But, because of the way things work, I can’t use it, so it’s next to useless, and after a few days running, so is this Sasktel unit.

Friday, November 13, 2009

Another rant… This time about WLW! (Updated!)

WLW being Windows Live Writer.

I’m not saying it’s bad (It’s actually rather good, IMHO), but there seems to be some kind of funky interaction between it and Blogger.

The source for a post, when it’s inside WLW looks like this:

<p>WLW being Windows Live Writer.</p>
<p>I’m not saying it’s bad (It’s actually rather good, IMHO), 
but there seems to be some kind of funky interaction between it and Blogger.</p>
<p>The source for a post, when it’s inside WLW looks like this:</p>

But, when it’s posted to blogger, it comes out like this:

<p>WLW being Windows Live Writer.</p>
<br />
<br />
<p>I’m not saying it’s bad (It’s actually rather good, IMHO), 
but there seems to be some kind of funky interaction between it and Blogger.</p>
<br />
<br />
<p>The source for a post, when it’s inside WLW looks like this:</p>

Obviously, this isn’t right. It looks like blogger is replacing every newline character with a <br /> and a newline. This would be fine if I was composing in plain text, but the editor I’m using is already doing the work at making sure everything is nicely XHTML formatted – I don’t need the extra newlines.

This was, for a while, making everything look FAR too spaced out, until I tweaked my CSS like so:

.post-body br {
   display: none;
}
.post-body p > br {
   display: auto;
}

What does this do?

It tells browsers to not display any “BR” elements inside the “.post-body” div, and then overrides that to say DO display “BR”s that are directly inside “P” (Paragraph) elements.

This fixes the problem, but I have a feeling I’m going about this the wrong way. Anyone out there use WLW with a similar problem? How did you fix it?

[Update] Well, I found the problem. Hidden deep within the settings of Blogger, there is the option “Convert Line Breaks” that defaults to “Yes”, with the description:

If Yes is selected, single hard-returns entered in the Post Editor will be replaced with single <br /> tags in your blog, and two hard-returns will be replaced with two tags (<br /><br />).

The wording of this implies it’s only going to do it for items posted through the Blogger “Post Editor”, but it seems this enables this behaviour everywhere, including through the Blogger API.

Now that this is switched off, everything looks just right again.

So, my apologies WLW, it wasn’t your fault at all. Blogger: What were you thinking?

Python didn’t have it, anyway…

Now, however, it does. Kinda.

def Python_to_XML_String(inst, name):
   builder = "<" + name + ">"
   builder += Python_to_XML_String_Recursion(inst)
   builder += "</" + name + ">"
   return minidom.parseString(builder)
   
def Python_to_XML_String_Recursion(inst):
   # Put entire object inside an elem w/ same name as the class.
   builder = ""
   for attr in inst:
      value = inst[attr]
      if type(value) == types.DictionaryType:
         # Recursively process subobjects
         builder += '<' + attr + '>'
         builder += Python_to_XML_String_Recursion(value)
         builder += '</' + attr + '>'
      elif type(value) == types.ListType:
         builder += '<' + attr + '>'
         for item in value:
            if type(item) == types.DictionaryType:
               builder += '<Item>'
               builder += Python_to_XML_String_Recursion(item)
               builder += '</Item>'
            else:
               builder += '<Item>'
               builder += str(item).replace("&","&amp;").replace("<","&lt;")
               builder += '</Item>'
         builder += '</' + attr + '>'
      else:
         # Convert anything else to string, put it in an element
         builder += '<' + attr + '>'
         builder += str(value).replace("&","&amp;").replace("<","&lt;")
         builder += '</' + attr + '>'
   return builder

(Note: I need a better source colouring plugin for WLW. Anyone know of one?)

This code is pretty limiting:

  • It’ll pretty much only work with generic type objects ({}, [] and primitives), but that’s all I need.
  • It also relies on the str() function to convert everything into a string, with no typing. This means that booleans (True, False) stay capitalised, which could cause some problems if your code is expecting lower-case values, and dates are unformatted.
  • It returns a minidom object (Which, obviously, has to be imported). You can output this with a .toxml() call.
  • It relies on the first object being passed in being a dictionary object, and that there will never be a list inside a list. This could be coded around, but it’ll take more work (and more helper functions, to fill in the “missing” information.
  • It takes an initial “name” argument to define the outer object.

To use it, call it like this:

Python_to_XML_String({'Thing': 'Value', 'Object', ['Thing 1', 'Thing 2']},'MyObject')

And it’ll return (for that example) an XML object looking like this:

<MyObject>
   <Thing>Value</Thing>
   <Object>
      <Item>Thing 1</Item>
      <Item>Thing 2</Item>
   </Object>
</MyObject>

I hope this is helpful to someone else out there…

Thursday, November 12, 2009

Wow. Python doesn’t have that? (Updated!)

This is going to be a rant, just so you are forewarned.

I have an object in Python that I’ve built that looks something like this:

Object = {
   'User': {
      'IsBanned': False, 
      'IsModerator': True, 
      'UserID': 'test@example.com', 
      'IsAdmin': True, 
      'LogoutURL': '/_ah/login?continue=http%3A//localhost%3A8080/CURRENT_URL&action=Logout', 
      'Location': u'Here.', 
      'Key': 'agVmb3J1bXIKCxIEVXNlchgCDA', 
      'UserLevel': 9L, 
      'NickName': u'Testing this works'
   }, 
   'Forum': [
      {
         'SubForums': [
            {
               'Threads': 0, 
               'Description': u'Test Three', 
               'Key': 'agVmb3J1bXILCxIFRm9ydW0YBQw', 
               'Title': u'Sub Forum'
            }
         ], 
         'Threads': 0, 
         'Description': u'Testing', 
         'Key': 'agVmb3J1bXILCxIFRm9ydW0YAww', 
         'Title': u'First Test'
      }, 
      {
         'Threads': 0, 
         'Description': u'Testing Two', 
         'Key': 'agVmb3J1bXILCxIFRm9ydW0YBAw', 
         'Title': u'Second Test'
      }, 
      {
         'SubForums': [
            {
               'SubForums': 
                  [
                     {'SubForums': 
                        [
                           {
                              'Threads': 0, 
                              'Description': u'Testing yet again', 
                              'Key': 'agVmb3J1bXILCxIFRm9ydW0YCQw', 
                              'Title': u'Another Forum'
                           }
                        ], 
                        'Threads': 0, 
                        'Description': u'Testing even more', 
                        'Key': 'agVmb3J1bXILCxIFRm9ydW0YCAw', 
                        'Title': u'Test Four'
                     }
                  ], 
                  'Threads': 0, 
                  'Description': u'Another test from JSON...', 
                  'Key': 'agVmb3J1bXILCxIFRm9ydW0YBww', 
                  'Title': u'Test Three'
               }
            ], 
            'Threads': 0, 
            'Description': u'Testing that JSON submitting a forum works...', 
            'Key': 'agVmb3J1bXILCxIFRm9ydW0YBgw', 
            'Title': u'test'
         }
      ]
   }

Taking advantage of the SimpleJSON library, I can serialise this into JSON with a single call. But I can’t find anything to serialise it into XML.

Well, technically speaking, I can. But all the libraries I have found want to do a LOT of massaging of the data structure, making it complex and unwieldy. What I want is a simple XML representation, like this:

<Object>
   <User>
      <IsBanned>False</IsBanned>
      <IsModerator>True</IsModerator>
      <UserID>test@example.com</UserID>
      <IsAdmin>True</IsAdmin>
      <LogoutURL>/_ah/login?continue=http%3A//localhost%3A8080/CURRENT_URL&action=Logout</LogoutURL>
      <Location>Here.</Location>
      <Key>agVmb3J1bXIKCxIEVXNlchgCDA</Key>
      <UserLevel>9</UserLevel>
      <NickName>Testing this works</NickName>
   </User>
   <Forum>
      <Item>
         <SubForums>
            <Item>
               <Threads>0</Thread>
               <Description>Test Three</Description>
               <Key>agVmb3J1bXILCxIFRm9ydW0YBQw</Key>
               <Title>Sub Forum</Title>
            </Item>
         </SubForums>
         <Threads>0</Threads>
         <Description>Testing</Description>
         <Key>agVmb3J1bXILCxIFRm9ydW0YAww</Key>
         <Title>First Test</Title>
      </Item>
      <Item>
         <Threads>0</Threads>
         <Description>Testing Two</Description>
         <Key>agVmb3J1bXILCxIFRm9ydW0YBAw</Key>
         <Title>Second Test</Title>
      </Item>
      <Item>
         <SubForums>
            <Item>
               <SubForums>
                  <Item>
                     <SubForums>
                        <Item>
                           <Threads>0</Threads>
                           <Description>Testing yet again</Description>
                           <Key>agVmb3J1bXILCxIFRm9ydW0YCQw</Key>
                           <Title>Another Forum</Title>
                        </Item>
                     </SubForums>
                     <Threads>0</Threads>
                     <Description>Testing even more</Description>
                     <Key>agVmb3J1bXILCxIFRm9ydW0YCAw</Key>
                     <Title>Test Four</Title>
                  </Item>
               </SubForums>
               <Threads>0</Threads>
               <Description>Another test from JSON...</Description>
               <Key>agVmb3J1bXILCxIFRm9ydW0YBww</Key>
               <Title>Test Three</Title>
            </Item>
         </SubForums>
         <Threads>0</Threads>
         <Description>Testing that JSON submitting a forum works...</Description>
         <Key>agVmb3J1bXILCxIFRm9ydW0YBgw</Key>
         <Title>test</Title>
      </Item>
   </Forum>
</Object>

It seems, however, that there is no Python library that can do that for me.

So why, I hear you asking, do I need such a thing?

Well, as you can probably tell from the listing(s) above, I’m writing an AJAX forum system. I’m doing it in Python so I can host it on Google App Engine (for free!), and can release it as open-source, but I’ve run into a pretty major snag.

I was using JSON to send data back and forth, which was working well. But I’ve found out that when you try and post using JSON to a different server (As the App Engine server will be, this is intended to be a “Widget” to use with Google Sites, among other things), an OPTIONS request is sent first to see if the cross-site request is allowed. I’ve grabbed the OPTIONS request, and replied with an “approved” message, but (even more to my consternation), the subsequent post from App Engine is empty. Oh, and cookies set before (on the GET) are not being sent with the POST, either. Thus I have decided to try switching to XML, and have run across the above roadblock.

I’m sure there are ways to do it, but searching across the ‘net has returned nothing. So I’m going to have to throw this open to the blogosphere, and hope something comes up. And soon.

[Update] As I found no-one had invented this particular wheel for me, I decided to roll my own, if you’ll excuse the pun(s).

Friday, July 17, 2009

What’s all the kerfuffle about “Universal Healthcare”?

Okay, I know I don’t post here often, but I have to say something here about this “Universal Healthcare” hoopla that’s going on in the US as they finally catch on to what the rest of the developed world has known for a LONG time now.

Universal Healthcare is a GOOD thing.

I will note here that my opinions here are primarily related to my experiences in the UK, under the NHS. That being said, let’s begin.

Everyone (And I do mean everyone) is eligible to receive care under the NHS. Poor? You’re covered. Student? You’re covered too. Unemployed? Yup, you’re fine. Working? Sure, you can still take advantage of the NHS. Multi-Millionaire? You can get it too. When we say “Universal”, we mean “Everyone”.

You want a doctor? Go pick one out of the phone book. Need to go to hospital? Call 999 (The UK equivalent of 911), and they’ll take you to the closest one, no charge. Need medicine? If it’s available OTC, just go to your local pharmacy and buy it. If it’s prescription only, go to your doctor. They’ll make sure you actually, medically, need it, and give you a scrip for it. Take that scrip to your pharmacy, pay £8.50 (Around $17), no matter what it is or how many there are, and pick up your drugs. Oh, and if you’re a full-time student, unemployed or retired, you pay nothing. Need to see the optician, or a dentist? That’ll set you back around £30 ($60), unless you’re a student, unemployed or retired, as above, then it’s free. Working with computers? Then your employer is legally required to pay for an eye check-up every 6 months. Need glasses? You can choose NHS-subsidised frames (Generally not the most stylish, but they will certainly do the job), or you can go with a brand-name pair, of which part of the cost may be subsidised.

If you have plenty of money, or if your employer offers it, you can (also) choose to have private medical insurance. So if you need a prescription and you’re working, the insurance takes care of it. If you need a procedure, and the wait time is too long on the NHS, you can choose to have the procedure done in a private hospital on your private medical insurance. And typically, if you elect to have a procedure on the NHS, the private insurance will pay you the equivalent of how much it would have cost to be treated privately.

Doctors on the NHS are incentivised to keep their patients healthy. They get a bonus for things like helping patients quit smoking. In fact, doctors are paid on the quality of life of their patients, not the turnover rate or the cost saved.

It does have to be said, waiting times on the NHS are longer for some non-critical procedures, but as you have the option of going private to avoid that queue, it is a reasonable choice, and certainly better than no care at all.

At no point have I ever had a bureaucrat say “No”. In fact, I have never been refused any kind of medical treatment on the NHS. I’ve never had to wait overlong for a procedure (though in fairness, I’ve never had a life-threatening ailment), and I’ve never had a problem with the care I received.

I know full well it was paid for from the income tax taken from my paycheque, but the amount was never onerous and never left me destitute, and wages were paid well in relation to the job done and the costs involved. Indeed, looking at US wages and the cost of US health plans, an equivalent health plan would cost many times the amount I was paying for the entirety of my income tax.

Universal Healthcare is not socialism, just as a universal police service, or universal fire coverage is not socialism, just like a universal civil defence force (the army/navy/marines/coastguard) is not socialism. It’s the fulfilment of a fundamental human right. It’s the very first one, in fact. “Life, liberty and the pursuit of happiness”. So, what’s the problem? And why don’t you have this already?