<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Ciao, credo che questa bad practice funzioni fino alla versione
1.11 dopodiché mancherebbe qualcosa nelle dichiarazione dei
ForeignKey ...e poi, perchè vuoi reinventare la ruota?</p>
<p>un caro saluto</p>
<p>Franky<br>
</p>
<div class="moz-cite-prefix">Il 03/05/19 23:42, Carlos Catucci ha
scritto:<br>
</div>
<blockquote type="cite"
cite="mid:CAEaPG9QG_ehyxrcu6f9yGO1ja7gAD3n88L4PfAhFHYWzw=-fWg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Ho </span><a href="http://models.py/" target="_blank" rel="noopener noreferrer" style="box-sizing:border-box;background:0px 0px rgb(228,236,242);color:rgb(58,109,153);text-decoration-line:none;font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap" moz-do-not-send="true">models.py</a><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> come il seguente</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">class Roles( models.Model ):</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> role = models.CharField( max_length=30 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> level = models.IntegerField( default = 0 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">class Operators( models.Model ):</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> login = models.CharField( max_length=30 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> password = models.CharField( max_length=50 )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> role = models.ForeignKey( "Roles", related_name="Operators_Roles" )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> active = models.BooleanField( default=False ) </span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Definisco una funzione</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">def insert( table, data ):</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> tab = table( **data )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> </span><a href="http://tab.save/" target="_blank" rel="noopener noreferrer" style="box-sizing:border-box;background:0px 0px rgb(228,236,242);color:rgb(58,109,153);text-decoration-line:none;font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap" moz-do-not-send="true">tab.save</a><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">()</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Provo a usarla e in effetti va tutto bene</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">insert( Roles, {'role': 'admin', 'level':1} )</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">insert( Operators, {</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'login': 'administrator',</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'password': 'xxxxxxx',</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'role_id': 1,</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"> 'active': True,</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">})</span><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><br style="box-sizing:border-box;color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Mi chiedo, perche' mi viene in mente che una cosa simile posa essere una bad practice?</span><br
clear="all">
</div>
<div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">
</span></div>
<div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Si accettano crtiche e pomodorate</span><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">
</span></div>
<div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">
</span></div>
<div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">Mi era venuto in mente per creare dei generici setters (Insert/Update e Delete) e getters (get_all, get_element_by_key, get_filtered_elements) e non dover fare la stessa cosa per ciascuna classe, ma ho idea che possa dare qualche problema</span><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">
</span></div>
<div class="gmail_default" style="font-size:small"><span style="color:rgb(0,0,0);font-family:Tahoma,sans-serif,Arial,Helvetica;font-size:13px;white-space:pre-wrap;background-color:rgb(228,236,242)">
</span></div>
<div>
<div class="gmail_default" style="font-size:small">Carlos</div>
</div>
-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">EZLN ... Para Todos Todo ... Nada para
nosotros<br>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Python mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Python@lists.python.it">Python@lists.python.it</a>
<a class="moz-txt-link-freetext" href="https://lists.python.it/mailman/listinfo/python">https://lists.python.it/mailman/listinfo/python</a>
</pre>
</blockquote>
</body>
</html>