[web2py] Re: Field set the default value +1 on insert

2015-11-21 Thread Bart van Berkel
Hello my friends,

Thanks for the inspiration.
The answer from Craig, looks to me a good idea how i can do it.

many thanks,

Bart

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Routes problem?

2015-11-10 Thread Bart van Berkel
Dit you also press the button reload routes after the change?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Field set the default value +1 on insert

2015-11-10 Thread Bart van Berkel
Hello web2py freaks,

In my first try to make an application with web2py i have a little struggle 
how to accomplish as what is would like to see.
In db1.py i created a field like this:

db.define_table('jobticket',
Field('ticket', 'integer', default = +1) # ticket needs to 
be ticket +1 when inserted
   )

I need to have something called "ticket" what represent a number where my 
other tables are linked to.

I know that the default id is auto increment, and i can reference it, so 
that's not the point. 

The ticket is a number what i needs to be set like : 15001. And that 
needs to be inserted +1 if there is a new job.
15 is a year, the rest is just a number.

So, i have 2 problems:
- if there is a new year like 1 january 2016, the first two numbers 
needs to be changed from 15 to 16?
- And how can i  get the max number out of the database and insert that 
with a new value( +1)

Does anybody have a good insperation or an good idea to get me on the right 
track?

Many thanks.

Bart




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: When i JOIN something it goes ok, but if there is no join i got an error..

2011-02-08 Thread Bart van Berkel

Hi villas,

Thnx for your reply.

I am only playing for a couple of day's with web2py and python.
I have more experience in php. ;)

As what i see now is that the JOIN is not correct i think..
going to give it another try.

speak to you later.

regards Bart
On 8 feb, 19:00, villas  wrote:
> Hi Bart
>
> I'd take a look at whether you are producing the correct SQL. Try
> placing an underscore in front of your select to expose in the
> commandline console whether the SQL is what you want. See the
> underscore here:
>
> print db(db.topics.id== request.args(0))._select(db.topics.title,
> db.topics.content,db.replys.content,left=db.topics.on(db.topics.id==db.replys.topic_id))
>
> You can then play around with the query until you get it right. Sorry
> I'm not answering your question directly but it's often better to show
> a man how to fish :-)
>
> -D
>
> On Feb 8, 8:55 am, Bart  wrote:
>
> > Hi all,
>
> > Just starting with Web2py and i feel like a kid in a play garden. ;)
>
> > Ok my problem, i am trying to make a simple JOIN but when i do that i
> > have a problem with my views.
> > My controlle looks like this:
>
> > def read():
>
> >     thispage = db.topics[request.args(0)]
>
> >     if not thispage:
> >       redirect(URL(r=request, f='read'))
>
> >     if auth.user_id:
> >         form = form = SQLFORM(db.replys)
> >         form.vars.topic_id = request.args(0)
> >         form.vars.user_id = auth.user_id
> >         if form.accepts(request.vars, session):
> >             response.flash = 'Topic created!'
> >     else:
> >        form = 'need to login to reply'
>
> >     db(db.topics.id==request.args(0)).select()[0]
> >     #topics = db(db.topics.id==request.args(0)).select(db.topics.id==
> > db.replys.topic_id)
> >     #replys =
> > db(db.replys.topic_id==request.args(0)).select(db.replys.ALL,
> > orderby=~db.replys.posted)
> >     #query = (db.topics.id==db.replys.topic_id)&(db.topics.id ==
> > request.args(0))
> >     rows= db(db.topics.id== request.args(0)).select(db.topics.title,
> > db.topics.content,
> >                                                     db.replys.content,
> > left=db.topics.on(db.topics.id==db.replys.topic_id))
>
> >     return dict(rows=rows,form=form)
>
> > My view looks like this:
>
> > {{extend 'layout.html'}}
>
> >    {{for row in rows:}}
> >    {{=row.topics.title}} 
> >     {{=row.topics.content}}
> >   {{pass}}
>
> >    {{for row in rows:}}
> >       
> >     {{=row.replys.content}}
> >   {{pass}}
>
> >    {{=form}} 
> > When i have a few reply's then i have row.topics.titles and
> > row.topics.content as the same amount as the row.replys.content.
> > When i don't have a reply, then i don get the record back from topics.
>
> > Now my question: How do i get one time the topics record back, and
> > when there is none replys just the the record of the topic?
>
> > What am i missing at this point?
>
> > Thanks for the help.
> > regards, Bart
>
>