No type definition on plugins' settings type

Bráulio Bhavamitra braulio at eita.org.br
Wed Oct 30 16:35:25 BRST 2013


On Wed, Oct 30, 2013 at 2:26 PM, Antonio Terceiro
<terceiro at colivre.coop.br>wrote:

> On Wed, Oct 30, 2013 at 12:01:51PM -0300, Bráulio Bhavamitra wrote:
> > Hello all,
> >
> > Noosfero::Plugin::Settings doesn't allow type definition. This is a huge
> > problem: imagine that you use a form and have a check box (boolean type).
> > The boolean type will not type cast from the string "false" to false, and
> > when the variable is checked it will be considered true, as if "false" is
> > considered true!
> >
> > Any suggestion on how to fix that?
>
> using act_as_having_settings on top of that?
>
> e.g. (untested)
>
> class MyPlugin < Noosfero::Plugin
>
>   def settings
>     @settings ||= Noosfero::Plugin::Settings.new(profile, self)
>   end
>
>   acts_as_having_settings
>   settings_items :my_checkbox, :type => :boolean
> end
>
> maybe this could even be streamlined to avoid plugins having to
> duplicate this pattern
>

Rodrigo:
I personally think this is a bug which pottencially creates other bugs. I
agree that a solution for this should be streamlined. Serialization without
types isn't very helpful.

Terceiro:
I'm extending the class Profile, so I defined:
class Profile
  def consumers_coop_settings
    @consumers_coop_settings ||= Noosfero::Plugin::Settings.new self,
ConsumersCoopPlugin
  end
end

So I can't use acts_as_having_settings for two reasons:
- It would overwrite the original
- It cannot work on a data already serialized (only on real fields)

In the example you gave it doesn't make sense 'settings_items :my_checkbox,
:type => :boolean' inside MyPlugin if it is related to the Profile, right?

regards,
bráulio


> --
> Antonio Terceiro <terceiro at colivre.coop.br>
> Colivre - Cooperativa de Tecnologias Livres
> http://www.colivre.coop.br/
>
>
>
> _______________________________________________
> Noosfero-dev mailing list
> Noosfero-dev at listas.softwarelivre.org
> http://listas.softwarelivre.org/cgi-bin/mailman/listinfo/noosfero-dev
>
>


-- 
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar

EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br

"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é meu
lar e todos nós somos cidadãos deste cosmo. Este universo é a imaginação da
Mente Macrocósmica, e todas as entidades estão sendo criadas, preservadas e
destruídas nas fases de extroversão e introversão do fluxo imaginativo
cósmico. No âmbito pessoal, quando uma pessoa imagina algo em sua mente,
naquele momento, essa pessoa é a única proprietária daquilo que ela
imagina, e ninguém mais. Quando um ser humano criado mentalmente caminha
por um milharal também imaginado, a pessoa imaginada não é a propriedade
desse milharal, pois ele pertence ao indivíduo que o está imaginando. Este
universo foi criado na imaginação de Brahma, a Entidade Suprema, por isso
a propriedade deste universo é de Brahma, e não dos microcosmos que também
foram criados pela imaginação de Brahma. Nenhuma propriedade deste mundo,
mutável ou imutável, pertence a um indivíduo em particular; tudo é o
patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20131030/3a8695ca/attachment.html>


More information about the Noosfero-dev mailing list