In Morocco elections are coming and the government is keen to show it is embracing democracy. But Richard Hamilton has been discovering that the real power may still be far removed from parliament.
The mausoleum of Moulay Ismail in Meknes is one of Morocco's most seductive monuments. Its yellow walls, keyhole arches, and intricate tile flooring make it a favourite with tourists.
But Sultan Moulay Ismail was not, by all accounts, a very nice man.
Sultan Moulay Ismail's mausoleum is a big tourist attraction
In fact the founding father of the Moroccan royal Alawite dynasty, which has continued from the 18th Century to the present day, was a tyrant whose excesses would have made Caligula blush.
There is a story that when his architect had completed the sumptuous gate of Bab Mansour at Meknes, the sultan enquired if he could do better.
Aware that this was the ultimate no-win situation, the draftsman replied "Yes".
At this point, he was led away and executed.
It is estimated that 30,000 others also met their deaths at the hands of the sultan - often for no reason.
Mounting his horse, Moulay Ismail would slash the head off a eunuch who had been adjusting his stirrup.
Even the walls of Meknes are filled with blood. When his slaves died, often of exhaustion, he found a use for them - as building material, mixing their blood with limestone.
When he inspected building sites, the sultan would carry a weighted lance so he could batter the skulls of labourers and encourage others to work harder.
He amused himself with 500 concubines and fathered hundreds of children. But when baby girls were born, he ordered them to be strangled at birth. If boys did not behave, he sliced their limbs off.
"My subjects are like rats in a basket," he said.
"And if I do not keep shaking the basket, they will gnaw their way through."
'Beacon of democracy'
Since the time of Moulay Ismail, the kings of Morocco have become progressively more enlightened, resulting in today's monarchy under Mohammed VI.
By all accounts Mohammed is a nice man and if he shakes the basket at all, it is slowly and gently or "shwia shwia", as they say here.
King Mohammed VI has improved human rights in the country
The king has slowly introduced reform, changed the family law and improved human rights.
People say Morocco is a beacon of democracy in the Arab world, certainly more liberal than neighbouring Algeria and Tunisia.
When I first arrived in Morocco, I took a stroll down the old medina in Rabat and ambled past traders in the crowded souk selling vegetables, spices and halal meat.
Then a strange thing happened.
A young man picked up a butane gas canister and pointed it at me.
To howls of laughter from his friends, he pretended it was a weapon and imitated the staccato sound of a sub-machine gun.
I smiled nervously and quickly made my way back to my apartment.
I had almost forgotten about this bizarre incident until I was reminded of it recently by something much more serious.
In Meknes recently, near the mausoleum of Moulay Ismail, a young government civil engineer picked up a gas canister in the main square, walked towards a coach load of tourists and detonated it.
In the split second before it exploded, the bus driver managed to shut the door of the coach and none of the passengers was injured.
The would-be suicide bomber lost his arm in the blast.
This is the shadow that lurks behind these elections - the spectre of Islamic extremism that has adopted terrorism as a means of expression.
The interior ministry has raised its alert to its highest level warning of attacks on tourist sites.
There is a legitimate Islamist party - the moderate PJD - and if such a party wins, that would be unusual in the Arab world.
But its chances have been blunted by the gerrymandering of electoral constituencies and the fact that the king still appoints key ministers.
Critics say that is what makes these elections - touted as democratic - far from that.
Another thing I noticed when I first came to Rabat, was that the police were making raids in the medina on street traders selling illegal copies of DVDs.
Under pressure from the likes of Hollywood, the Moroccan government was keen to show that it was tough on piracy and seized millions of discs, putting the salesmen in jail.
But, as the months went by, the traders started trickling back slowly - "shwia shwia" - and furtively set up makeshift stalls in the narrow alleyways.
The other day I saw two policemen inspecting a DVD stall. But they were not going to close it down - they were wondering which films to watch that evening.
In a sense, the Moroccan elections are a bit like this.
Under pressure from the likes of Washington, the government is keen to show that it is embracing democracy.
So it holds a poll that it says will be free and fair, and looks ostensibly democratic.
But things are not always as they appear in Morocco.
A potential winner like the PJD is likely to be thwarted by the system.
Because the real power lies not with the men in parliament anyway but with another man - the Commander of the Faithful, King Mohammed VI - even if his kingdom has come a long way since the days of Moulay Ismail and his subjects are no longer rats in a basket.
From Our Own Correspondent was broadcast on Saturday 1 September, 2007 at 1130 BST on BBC Radio 4. Please check the programme schedules for World Service transmission times.