Legality of cannabis cultivation in Portugal/Netherlands

I was reading about a new bill in Uruguay that would legalise the cultivation, distribution and consumption of cannabis. The law in itself is not the question here, but rather what I read on this Foreign Policy story:

This made me think: does this mean that the cultivation of marijuana is NOT legal in Portugal and the Netherlands? In that case, what kind of legal loophole do Amsterdam’s ‘coffee houses’ exploit to get the weed they later sell legally? It just doesn’t make sense to me that selling a drug might be legal, but not cultivating it.

(Or maybe I’m mis-reading the article, please tell me if that’s the case)

No need to jump across the border: have an article from this same year, La Voz de Galicia March 3rd, on the situation in Spain. I found it looking for reports on some story I remember seeing in the news in maybe May, about a coop setting up an industrial-scale field somewhere in I-think-Girona: the field is industrial scale, but access to its product is supposed to be restricted to coop members, so they claim that makes it fall under “personal use”. I don’t know whether the fiscalía decided to drop the issue or not, but the article mentions that there are many coops like that one.

That’s right: growing more than three plants for personal use is not legal in the Netherlands. The coffeeshops illegally buy in their wares, which is officially tolerated through a policy called “gedoogbeleid”.

It is a misconception that you are allowed to grow any number of plants for personal use. If the police see them; they’ll take them away, but they won’t prosecute you if the number of plants is below 5.

Dutch Link

English (From Dutch)

Thank you. I assumed there was a ‘legal loophole’ somewhere, but it’s nice to have it confirmed