On Wed, Mar 11, 2009 at 9:04 PM, DenesL <[email protected]> wrote:
*snip*

@Massimo
>
> > What about the syntax:
> >
> > db.define_view('myview',db.Field('col1'),db.Field('col2'),select=db
> > (...)._select(....))
>
> My first idea is more along the lines of:
>
> db.define_view('viewname',sqlset,fields=[],maybe_labels=
> [],mapidto=...)



I'm not sure how to read this...  or how to use this...

I need to see the proposed web2py syntax    just below the equivalent create
viiew SQL...

I don't immediately see how I would accomplish:

select  legacy_table1.primary_key as id legacy_table2.name as name
legacy_table1.xxx as xxx ....

What is mapidto??? why is this any different than any other "SELECT  t1.a as
a, t2.b as b...."?


>
> so when you create your view, e.g.:
> db.define_view('v1',db.person.id==db.dog.owner,fields=
> ['person.name','dog.name'],...)


I'm confused...   do I write name=db.V1.name?  db.V1.person.name?   This
doesn't look like the other db/table/column   syntax anymore - how is this
going to work???

Also - what is person.name?  Is is a string? how long?  Text?  something
else?  where do I specify that so web2py can handle what it reads?

Let me merge my earlier comment w/ your (just to try it - I still don't know
if I like this --- BUT NOTE:  I'm trying to be much, much closer to
define_table() syntax):

s= //some arbitrary select syntax -- and here's the rub: it has to refer to
a db and table, which??? does this need table definitions?  or do we
accomplish this in the view definition?  how? db.define_foreign_table ???//

Look at http://www.firebirdsql.org/refdocs/langrefupd20-create-view.html
which gives a nice hint:  it's just CREATE VIEW name as SELECT....

Ok - let me ignore this for the moment - it will push the next thing that
breaks I think...

db_foreign.define_view( 'view_one', s,  VIEWField( {'id' :
foreign_table1.foreign_primary_key}),
VIEWField({ 'name' : foreign_table2.name1}),
VIEWField({ 'comment' : foreign_table1.comment})
)

# this needs to work:
db.sometable.requires=IS_IN_DB( db_foreign, 'view_one.id', %(name)s)

It's coming somewhat clear that we need something like a:

db.foreign_table()   which works like db.table_define(), only it does not
allow access, does not assume ANY 'id' field, and is only used to build up
the select statements that will go into views.

Views, in turn must ... MUST be required (I think) to have an 'id' mapping
(as I show)  defined, or it's an error.  Without this, compatibility with
existing code cannot happen (am I right?).



>
> translates in sqlite to
> cursor.execute('create view v1 as select person.name, dog.name from
> person join dog on person.id = dog.owner')


So --- does this create v1.name, v1.dog, .... ???


>
>
> after which you can:
> db.v1.select()
> equiv. to
> cursor.execute('select * from v1')
>
> > A view would be a special table that does not have an "id" field and
> > does not support insert.
>
> No id for non-web2py tables, map to something else.
> Why not insert? don't use SQLFORM use VIEWFORM ;-)


how will anything work if no id field in the view? wasn't this the entire
point of this????

What am I missing? Without id, not only do you need to replace SQLFORM with
VIEWFORM... you begin to need to do that with EVERYTHING...

This feels like a mistake.

Consider what will NO DOUBT be a very useful application:

Create a view into OLD or someone elses data (which you are not free to
change the definition of, or maybe even write)  but based on that data, you
extend it --- create a view for (say) customer support.... or view a code
repository, and extend it with a view that merges comments to code....

That is - foreign table + web2py generated (standard) table ==> view.


Let's keep at this - for as I read, and have all my reactions (both
positive, and spotting potential trouble) one thing that is beginning to
emerge - this has the potential to be very useful.

I am already thinking of PyCon2010 and collaborative site (web2py-django ---
as it is, one of our tasks is to go beyond  working side-by-side, with just
hyperlinks, to a little more cooperation / collaboration - a hybrid site -
and that means common tables - e.g. person / login, for one example).


Yarko.


>
> (Warning: this ideas are just brainstorming and need to be refined).
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to