[web2py] CRUD and controllers

2010-07-21 Thread Running Clam

Hi,

I've been trying to get to grips with CRUD after previously doing things 
mostly manually, but I seem to have fallen at the first hurdle with 
"crud.tables()".


If I call crud.tables() from a function called tables in MyController 
and just let the generic template render it, I do get the expected list 
of tables.


However, I get links to e.g.: -

/app/default/tables/select/tablename

...as opposed to the expected: -

/app/MyController/tables/select/tablename

...IOW, I'm seeing "default" in place of the name of my own controller.

It may or may not be relevant, but if I click on those links, I reach 
the expected URL, but I see only the list of tables - not as expected a 
list of records in the selected table.


Can anyone clue me in as to what I am doing wrong, please?

I feel as though I'm either missing something fundamental, or I've hit 
unexpected behaviour...


I'd love to see more examples on the web of CRUD usage - pointers to any 
good resources with examples would be very welcome.



---

Thanks,

Clam


Re: [web2py] Re: CRUD and controllers

2010-07-21 Thread Running Clam

Hi Massimo,

On 21/07/10 13:46, mdipierro wrote:

Crud does not determine in which controller it is called. You need to
do

crud.settings.controller = 'MyController'

I may be able to change this behavior anyhow.



Aha - I had not realised this. Links in the data returned by 
"crud.tables()" are now formed as expected.


However, if I follow a link to e.g.: -

../MyApp/MyCtl/tables/select/auth_user

...the page at that URL is identical to that returned by "crud.tables()" 
- which makes sense insofar as it is calling the same function in the 
same controller, but leaves me wondering how the "/select/auth_user" 
part should work? The documentation lists the URLs exposed by CRUD, but 
does not tell me what else I might need to do to use them.


I could form CRUD links in the list of tables in the template, but I 
can't see how to access the table name and href in the returned object, 
possibly because I am not yet up to speed with HTML helpers.


Am I missing something, or am I right in concluding that I should sort 
out the links myself?


Can you give me a pointer as to how to list the tablename and href "as is"?

I'm sorry - I'm feeling rather dim about this...

Thanks in anticipation!

--

Clam


[web2py] URL formation in CRUD

2011-01-26 Thread Running Clam
Hi,

Having used web2py for a while using hand-written controllers and
views, I'm trying to see how far I can get with CRUD alone, but I'm
seeing some odd behaviour.

If I create a controller called crm.py, and define "data" as a
function as described in the book, when I call the function, [app]/crm/
data redirects to [app]/default/data/tables, e.g. reverting the
controller name "crm" to "default".

While I considered this I actually moved my function to default.py so
I could carry on experimenting.

>From the list of tables exposed at /default/data/tables, I can drill
down to a list of records at e.g. [app]/default/data/select/client.
However, if I attempt to drill down to the first record, I end up at
[app]/default/read/client/1, which fails as the function name "data"
is missing.

Have I done something silly? My test examples are very simple, so I'm
baffled.


--

Thanks for any help,

Clam


[web2py] Re: URL formation in CRUD

2011-01-27 Thread Running Clam

If this isn't something anyone else has encountered, can anyone clue
me in as to how to start digging into this?

I'm not sure whether to start with my own set-up (Windows, Version
1.91.6), or dive into the web2py source, which I've not had reason to
do before...


[web2py] Re: URL formation in CRUD

2011-01-27 Thread Running Clam
Hi,

On Jan 27, 1:56 pm, web2py noob  wrote:
> ref:http://web2py.com/book/default/chapter/07#CRUD
>
> crud.settings.controller = 'crm'
>

D'Oh!

Will retest and report back as to how I got on.


--

Clam


[web2py] Re: URL formation in CRUD

2011-01-27 Thread Running Clam
Hi,

OK, specifying the controller as follows: -

crud.settings.controller = 'crm'

...as suggested by web2py.n00b resolves the controller name issue, and
I feel suitably foolish for having overlooked it.

However, the omission of the "data" function name still happens when I
drill down to a record: -

- at [app]/crm/data/tables I see my list of tables, and can drill down
to one, e.g. "client".

- at [app]/crm/data/select/client I see my list of clients, but in the
link behind the ID it omits the function name "data", and so takes me
to [app]/crm/read/client/1 which throws rightly throws "invalid
function (crm/read)", instead of the correct URL of "[app]/crm/data/
read/client/1".

What am I missing?

--

Clam


[web2py] Re: Bugfix for full CRUD internal read links

2011-01-29 Thread Running Clam
Hi Bernd,

Thank you - I think that solves a problem I've been wrestling with.

--

Clam


[web2py] Re: URL formation in CRUD

2011-01-29 Thread Running Clam
See: 
http://groups.google.com/group/web2py/browse_thread/thread/8aab803ada993cd3#


[web2py] Search form in CRUD

2011-02-01 Thread Running Clam
Hi All,

If I call "search" from a controller like: -

def client_search():
return dict(form=crud.search(db.client))

...and get the expected form, but using: -

def data():
return dict(form=crud())

...at: -

[app]/crm/data/search/client

...I get a 404.

Am I missing something?

--

Cheers,

Clam


Re: [web2py] Search form in CRUD

2011-02-03 Thread Running Clam

Hi All,

Not sure if anyone else has worked through the CRUD URLs described in 
the book on p317, but the search URL described does not work: -


def client_search():
return dict(form=crud.search(db.client))

...works as expected, but using: -

def data():
return dict(form=crud())

...and visiting the URL indicated by the book: -

[app]/[controller]/data/search/client

...throws a 404.

I'm not sure if this is a bug, or if the book is incorrect?


--

Cheers,

Clam


[web2py] Next record in crud.create

2011-02-06 Thread Running Clam

Hi All,

Using CRUD methods, in a controller I have: -

def update():
crud.settings.showid = True
crud.settings.update_next = URL('view', 
args=[request.args(0),request.args(1)])

return dict(form=crud.update(db.accmgr,
request.args(1)))

...and update_next takes me to view the record updated, using the id in 
the request to identify the record.


If I try to do the equivalent with an insert, I need to access the ID of 
the inserted record, which I had understood to be accessible via 
"form.vars.id" but if I try: -


def add():
crud.settings.create_next = URL('view', args=['accmgr', 
form.vars.id])

return dict(form=crud.create(db.accmgr))

...I get an error ticket telling me that "form is not defined".

I have read that "form.vars.id" works with "onaccept", because 
"onaccept" is called with "form" as a parameter after the form is

accepted, but that does not seem to apply here.

Do I need to somehow explicitly make the "create_next" conditional on 
the form having been accepted, or is there a different syntax I can use 
to access the "id", or am I on the wrong track entirely?



--

Cheers,

Clam


Re: [web2py] Re: Next record in crud.create

2011-02-06 Thread Running Clam

Hi Massimo,

On 06/02/2011 16:03, Massimo Di Pierro wrote:

There is a shortcut for this:

def add():
  return dict(form=crud.create(db.accmgr,next='view/[id]'))



Sorted - Thanks!


--

Cheers,

Clam


Re: [web2py] Test if client has javascript

2011-02-09 Thread Running Clam

Hi,

On 09/02/2011 09:46, m momin wrote:

stop my mesage



Every message from the list has a hint in the headers as to how to 
un-subscribe: -


List-Unsubscribe: 
, 



You are sending your instructions to the group members, who cannot help 
you - only you can manage your subscription.


HTH


--

Cheers,

Clam