On sab, 2008-09-20 at 22:12 +0200, Christian wrote:
> Salve a tutti,
> da un po di giorni mi sto cimentando con turboGears e sto incontrando
> problemi a mappare una classe ad una vista del mio database
> (Postgresql).
> Il mio database di esercizio ha una tabella:
> 
> CREATE TABLE utente
> (
>   id serial NOT NULL,
>   user_name character varying(20) NOT NULL,
>   first_name text,
>   middle_initial character varying(1),
>   last_name text,
>   CONSTRAINT utente_pkey PRIMARY KEY (id),
>   CONSTRAINT utente_user_name_key UNIQUE (user_name)
> )
> 
> ed una vista:
> 
> CREATE OR REPLACE VIEW v_utente AS 
>  SELECT u.id, u.user_name AS uname, u.first_name AS fname
>    FROM utente u;
> 
> Nel model vorrei mappare due classi direttamente dal database con
> sqlmeta e l'attributo formDatabase:
> 
> class Utente(SQLObject):
>       class sqlmeta:
>               fromDatabase=True
> 
> class vutente2(SQLObject):
>       class sqlmeta:
>               fromDatabase=True
>               table="vutente2"
>               idName="id"
Ho incollato una vecchia versione (scusate):
class vutente2(SQLObject):
        class sqlmeta:
        fromDatabase=True
        table="v_utente"
        idName="id"
(L'errore ovviamente resta...)
> 
> Il problema è proprio sulla vista che mi riporta sempre il seguente
> errore quando eseguo il comando sql-admin shell:
> 
> assert primaryKey, "No primary key found in table %r" % tableName
> 
> Leggendo sulla documentazione di SQLObject, ho visto che uno dei vincoli
> è la necessità di avere un solo campo come PK, ma la vista si appoggia
> ad una tabella (è la stessa) con un unico campo di PK.
> 
> Qualcuno sa dirmi come fare per creare una classe che mappi una VISTA?
> 
> Grazie e spero di essere stato sufficentemente chiaro
> 
> Christiam
> 
> 
> _______________________________________________
> Python mailing list
> Python@lists.python.it
> http://lists.python.it/mailman/listinfo/python

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Python mailing list
Python@lists.python.it
http://lists.python.it/mailman/listinfo/python

Rispondere a