[web2py] Re: Value error when forcing AM/PM time with time field

2016-08-29 Thread Dave S


On Monday, August 29, 2016 at 7:00:21 PM UTC-7, H. Das wrote:
>
> Hello everyone,
>
> I defined a simple table with time fields like so:
>
> db.define_table("time_block",
> Field("start_time", "time", requires=IS_NOT_EMPTY()),
> Field("end_time", "time", requires=IS_NOT_EMPTY()),
> )
>
> In jQuery I forced the time widget to show AM/PM like so:
>
> 
> jQuery.timeEntry.setDefaults({show24Hours: false, showSeconds: false});
> 
>
> Now after I submit the form with the time say, 10:33PM, I get this error at 
> the bottom of the traceback:
>   File "C:\...\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1553, 
> in parse_time
> time_items = list(map(int,str(value)[:8].strip().split(':')[:3]))
> ValueError: invalid literal for int() with base 10: '33PM'
>
> It appears that AM/PM is not being recognized by dal? Is there another way to 
> force AM/PM in time widgets instead of the default 24-hour? 
>
> My web2py version is Version 2.14.6-stable, I am using SQLite.
>
> Thanks.
>
>

I think you need to modify your time validator:

"This validator checks that a field value contains a valid datetime in the 
specified format. It is good practice to specify the format using the 
translation operator, in order to support different formats in different 
locales."

(The format string details are shown with IS_DATETIME(), but should apply 
to IS_DATE() and IS_TIME().)

 I think you can have that and the not-empty validator by using 
requires=[...] (list notation).

/dps

-- 
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] Value error when forcing AM/PM time with time field

2016-08-29 Thread H. Das
Hello everyone,

I defined a simple table with time fields like so:

db.define_table("time_block",
Field("start_time", "time", requires=IS_NOT_EMPTY()),
Field("end_time", "time", requires=IS_NOT_EMPTY()),
)

In jQuery I forced the time widget to show AM/PM like so:


jQuery.timeEntry.setDefaults({show24Hours: false, showSeconds: false});


Now after I submit the form with the time say, 10:33PM, I get this error at the 
bottom of the traceback:
  File "C:\...\web2py\gluon\packages\dal\pydal\adapters\base.py", line 1553, in 
parse_time
time_items = list(map(int,str(value)[:8].strip().split(':')[:3]))
ValueError: invalid literal for int() with base 10: '33PM'

It appears that AM/PM is not being recognized by dal? Is there another way to 
force AM/PM in time widgets instead of the default 24-hour? 

My web2py version is Version 2.14.6-stable, I am using SQLite.

Thanks.

-- 
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: one to many joins repeated parent

2016-08-29 Thread luis . valladares
Hello!

Thanks for your help! but it means that for every record inside events 
table i should do an additional query in the modificators table, so if in a 
query i want to get 100 events and his modificators i should do 101 queries 
to the database, i think (im not sure, i'll will talk tomorrow with the 
DevOps) that database queries are expensives.

Or instead, loop over all the modificators, find the ID, do a query using 
pydal belongs and do a matchup between the two responses to relationate 
each modificator to his respective events.

After i'll check this option tomorrow with my DevOps i will edit this 
message

El lunes, 29 de agosto de 2016, 9:17:20 (UTC-4), Mirek Zvolský escribió:
>
> With pydal (ie. db=DAL()) you can get the records in 2 queries:
> event = db(db.events.id == wish_event_id).select()
> and event_modificators = db(db.modificator.events_id 
> == wish_event_id).select()
>
> then convert to the list:
> event_modificators = [row for row in event_modificators]# item is 
> whole row
> or event_modificators = [row.modificator for row in event_modificators]   
>  # item is one field only.
>
> 
> If modificator has just 1 field (+ 2nd id field),
> then instead of solution with 2 tables you could use just 1 table with 
> Field(..., type="list:string").
> This has special support on Google App Engine NoSQL, but on any other SQL 
> database (SQLite, Postgres) it is supported as 'text' with '|' separators 
> inside. I think you will get a list immediately when asking for such field. 
> And it is supported in SQLFORM() too to set 1+ modificators.
>
>
>
>
>
> Dne neděle 28. srpna 2016 23:21:31 UTC+2 luis.va...@metamaxzone.com 
> napsal(a):
>>
>> Hello!
>>
>> I've this data structure in my database: i've two tables events and 
>> modificators, one event can have many modificators so i've a one to many 
>> relation. Im trying to build an HTTP endpoint that returns a json with 
>> multiple events and all the asociated modificators, i order to do this i do 
>> a join and return the select as a list, but my problem (and i understand 
>> this problem is related to the way SQL works) is that the parent is 
>> repeating on every record, so i've an event A with four modificators B, C, 
>> D and E i get something like this:
>>
>> [{"events": A, "modificator": B}, {"events": A, "modificator": C}, 
>> {"events": A, "modificator": D}, {"events": A, "modificator": E}]
>>
>> instead of this i want something like
>>
>>  [{"events": A, "modificator": [B, C, D, E]}]
>>
>> i now i can do this with a for and creating my own custom dictionary, but 
>> i think this problem will be repeated several times along the api im 
>> developing because my database has multiple one to many relations so it 
>> would be good to get some "generic" solution instead of creating a lot of 
>> nested fors for each case, also i think is a little bit inefficient doing 
>> it on this way.
>>
>> I was wondering if the DAL or web2py himself has some method for this, or 
>> if you can recomend a external library because i thinks this is a fair 
>> common case, even if you can give me some guidance to develop a common 
>> class, or function for this problem.
>>
>> By the way,  i read this example in the web2py manual:
>>
>> >>> for person in db().select(db.person.ALL):
>> print person.name
>> for thing in person.thing.select():
>> print '', thing.nameAlex
>>  Boat
>>  ChairBob
>>  ShoesCarl
>>
>> but i think it doesnt fit my needs because of the high database I/O, im 
>> deploying my app on EC2 (Amazon) and the databases instances have a really 
>> high cost, this is combined with my database having a LOT of records (about 
>> 2000 events and 5800 modificators) and growing.
>>
>>
>> Thanks for any help or guidance you can provide!
>>
>

-- 
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: Best and simpler approach to Inline editing / deleting / appending (jqGrid, Jeditable,etc)

2016-08-29 Thread Henk huisman
Hi Clara,
I have been looking for a powerful grid component too. Started using 
jqGrid.  It's really nice and very powerful; I recommend it.
Depends a bit on what license you looking for. For non-commercial 
organisations it's free.

Henk




 

>
>  
>

-- 
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: TAG helper and unnamed argument

2016-08-29 Thread Anthony
On Monday, August 29, 2016 at 6:46:33 PM UTC-4, Dave S wrote:
>
>
> Continuing the side-comment:
>
> On Monday, August 29, 2016 at 2:37:53 PM UTC-7, Niphlod wrote:
>>
>>
>> @mdipierro: [...]
>> BTW2: the referenced page with 
>> the new style is a pain to read
>>
>
> Scrolls very "slowly" for me ... mouse wheel or page down don't move very 
> far at a time.  Some of the colors don't stand out well on black backgrounds
> (teal, one of the reds, ...)
>

Same here.

-- 
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: TAG helper and unnamed argument

2016-08-29 Thread Dave S

Continuing the side-comment:

On Monday, August 29, 2016 at 2:37:53 PM UTC-7, Niphlod wrote:
>
>
> @mdipierro: [...]
> BTW2: the referenced page with 
> the new style is a pain to read
>

Scrolls very "slowly" for me ... mouse wheel or page down don't move very 
far at a time.  Some of the colors don't stand out well on black backgrounds
(teal, one of the reds, ...)

/dps
 

-- 
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.


Re: [web2py] Re: Best and simpler approach to Inline editing / deleting / appending (jqGrid, Jeditable,etc)

2016-08-29 Thread Tim Richardson
I wonder if in that case you are better making lots of individual forms.
That's what I would do.

On 24 August 2016 at 07:08, WeiI Wang  wrote:

> Hi Tim,
>
> I tried the inline edit for sqlform grid.
> The problem I have is there is only one submit button and whenever I edit
> something and submit, all the records' update time becomes the same.
> Is it possible to have one submit button for each row?
>
>
> On Friday, February 13, 2015 at 11:36:32 AM UTC-8, Tim Richardson wrote:
>>
>> there is this approach as well, which makes the existing SQLGRID.grid
>> widget editable.
>>
>> http://www.web2pyslices.com/slice/show/1928/basic-inline-edi
>> ting-in-sqlformgrid-no-plugin-no-javascript
>>
>>
>>
>> On Friday, 13 February 2015 22:36:48 UTC+11, clara wrote:
>>>
>>> Hello,
>>>
>>> Thanks all for the support and suggestions.
>>> I was able to get the slice using Jqgrid working (
>>> http://www.web2pyslices.com/slice/show/1714/jqgrid-viewing-
>>> and-updating-data). But I will take a look at the Massimo and Michael
>>> suggestions.
>>>
>>> Thanks again,
>>>
>>> Clara
>>>
>>>
>>> On Feb 11, 2015 1:25 PM, "Massimo Di Pierro" 
>>> wrote:
>>>
 I have used both and I think handsontable is much superior and
 customizable.

 On Monday, 9 February 2015 20:50:00 UTC-6, Michael Beller wrote:
>
> I've started using http://www.datatables.net/ primarily for the great
> search and responsive behavior.  I've read about the inline support but
> haven't tried it yet but it looks very good.
>
> The other option that looks very good is http://handsontable.com/ but
> I've only read through the documentation.
>
> On Saturday, February 7, 2015 at 11:00:45 PM UTC-5, clara wrote:
>>
>> Hello,
>>
>> I know this has been asked before, there are Web2py Slices (some of
>> which seem to be outdated), questions posted here on the subject but
>> somehow it is not clear to me which path I should take to implement a 
>> grid
>> with inline editable fields, appendable/deletable records. I am looking 
>> to
>> some "compact" solution which I am not sure it exist that would have the
>> functionality of current *SQLFORM.smartgrid*  but in addition to it:
>> inline editable fields and deletable/appendable records.
>>
>> I will greatly appreciate any input on this.
>>
>> Best regards,
>>
>> Clara
>>
>>
>>
>>
>>
>>
>>
> --
 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 a topic in the
 Google Groups "web2py-users" group.
 To unsubscribe from this topic, visit https://groups.google.com/d/to
 pic/web2py/ZFG0Z3-oQSg/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/ZFG0Z3-oQSg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Tim Richardson

-- 
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: TAG helper and unnamed argument

2016-08-29 Thread Niphlod
whoops, forget what I said. Apparently any attribute without a specific 
value is syntactically equivalent to "".
So, @Kirill, there's no way but ending up with _pubdate='' will give you a 
syntactically equivalent markup.

Unless I'm reading w3c spec wrong, in that case feel free to correct me.

On Monday, August 29, 2016 at 11:37:53 PM UTC+2, Niphlod wrote:
>
> ATM "False" or "None" don't have the corresponding attribute inserted. 
> There's no way to generate an attribute without value.
>
> BTW: that is definitely not a good example as it's not HTML5 valid syntax. 
> A better one could have been 
>
> http://n.example.org/rfc4287;>
>hi
> 
>
>
> @mdipierro: any thoughts about this ? If I'm not mistaken, the offending 
> line is from #L936 
>  to #L947 
>  ... 
> maybe _pubdate=None should result in an empty attribute ?
> BTW2: the referenced page with 
> the new style is a pain to read.
>
> On Monday, August 29, 2016 at 9:44:59 PM UTC+2, Kirill Shatalaev wrote:
>>
>>
>> So, how to do some like:
>>
>> 1 day ago
>>
>>
>> I tried:
>>
>>
>> TAG.time('1 day ago', _pubdate=True,
>>  _datetime=str(datetime.year) + '-' + '%02d' % datetime.month + '-' + '%02d' 
>> % datetime.day)
>>
>>
>> And got:
>>
>>
>> 1 day ago
>>
>>
>> Here I can read:
>>
>> http://www.web2py.com/init/default/examples
>>
>>
>> "attributes without value like "READONLY" can be created with the argument 
>> "_readonly=ON"."
>>
>>
>> But not _pubdate=True, nor _pubdate=ON (wich is deprecated and just an alias 
>> for True according to chapter 5) does not work for me and generates 
>> pubdate="pubdate".
>>
>>
>>
>>
>>
>>
>>

-- 
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: TAG helper and unnamed argument

2016-08-29 Thread Niphlod
ATM "False" or "None" don't have the corresponding attribute inserted. 
There's no way to generate an attribute without value.

BTW: that is definitely not a good example as it's not HTML5 valid syntax. 
A better one could have been 

http://n.example.org/rfc4287;>
   hi



@mdipierro: any thoughts about this ? If I'm not mistaken, the offending 
line is https://github.com/web2py/web2py/blob/master/gluon/html.py#L936
BTW2: the referenced page with 
the new style is a pain to read.

On Monday, August 29, 2016 at 9:44:59 PM UTC+2, Kirill Shatalaev wrote:
>
>
> So, how to do some like:
>
> 1 day ago
>
>
> I tried:
>
>
> TAG.time('1 day ago', _pubdate=True,
>  _datetime=str(datetime.year) + '-' + '%02d' % datetime.month + '-' + '%02d' 
> % datetime.day)
>
>
> And got:
>
>
> 1 day ago
>
>
> Here I can read:
>
> http://www.web2py.com/init/default/examples
>
>
> "attributes without value like "READONLY" can be created with the argument 
> "_readonly=ON"."
>
>
> But not _pubdate=True, nor _pubdate=ON (wich is deprecated and just an alias 
> for True according to chapter 5) does not work for me and generates 
> pubdate="pubdate".
>
>
>
>
>
>
>

-- 
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.


Re: [web2py] Re: DAL size limit for query?

2016-08-29 Thread Dave S


On Monday, August 29, 2016 at 1:25:33 PM UTC-7, goome wrote:
>
> > 
> >> moreover, i should 'append' the row to a pydal.objects.Rows 
> >> as to say 
> >> dati += row 
> >> but how can i do this? 
> >> 
> >> 
> > That one looks easy:  data.append(row) 
>
> but how can i create first 'data' as a  pydal.objects.Rows? 
>

Well, that's the answer to your first question, which I can't provide.  It 
may help other helpers though if you show your define_table() statements.

/dps
 

> > 
> > 
> >> Thank you a lot again 
> >> 
> >> 
> > Good luck! 
> > 
> > /dps 
> > 
> > 
> >> 
> >> 2016-08-04 9:52 GMT+02:00, c...@cemeren.com  < 
> >> c...@cemeren.com >: 
> >> > You may try using iterselect() instead of select() if the issue is 
> >> memory 
> >> > related. 
> >> > 
> >> > The link to the book is below. 
> >> > 
> >> > 
> >> 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=Using-an-iterator-based-select-for-lower-memory-use#Using-an-iterator-based-select-for-lower-memory-use
>  
> >> 
> >> > 
> >> > On Thursday, August 4, 2016 at 10:35:13 AM UTC+3, goome wrote: 
> >> >> 
> >> >> 2016-08-04 1:08 GMT+02:00, Dave S  >: 
> >> >> > 
> >> >> > 
> >> >> > On Wednesday, August 3, 2016 at 2:33:35 PM UTC-7, goome wrote: 
> >> >> >> 
> >> >> >> when trying in the shell, the shell itself got killed : 
> >> >> >> >> In [4]: legacy_db(query).select() 
> >> >> >> >> 
> >> >> >> >> Killed 
> >> >> >> >> root@rb:/home/www-data/web2py# 
> >> >> >> 
> >> >> >> 
> >> >> > Is that using web2py in a bash/python shell  (i.,e., -M -S myapp) 
> ? 
> >> >> yes, this one 
> >> >> 
> >> > 
> >> > -- 
> >> > 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 a topic in 
> the 
> >> > Google Groups "web2py-users" group. 
> >> > To unsubscribe from this topic, visit 
> >> > https://groups.google.com/d/topic/web2py/nqUnVx62GE0/unsubscribe. 
> >> > To unsubscribe from this group and all its topics, send an email to 
> >> > web2py+un...@googlegroups.com . 
> >> > For more options, visit https://groups.google.com/d/optout. 
> >> > 
> >> 
> > 
> > -- 
> > 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 a topic in the 
> > Google Groups "web2py-users" group. 
> > To unsubscribe from this topic, visit 
> > https://groups.google.com/d/topic/web2py/nqUnVx62GE0/unsubscribe. 
> > To unsubscribe from this group and all its topics, send an email to 
> > web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
> > 
>

-- 
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.


Re: [web2py] Re: DAL size limit for query?

2016-08-29 Thread Marcello Console
>
>> moreover, i should 'append' the row to a pydal.objects.Rows
>> as to say
>> dati += row
>> but how can i do this?
>>
>>
> That one looks easy:  data.append(row)

but how can i create first 'data' as a  pydal.objects.Rows?
>
>
>> Thank you a lot again
>>
>>
> Good luck!
>
> /dps
>
>
>>
>> 2016-08-04 9:52 GMT+02:00, c...@cemeren.com  <
>> c...@cemeren.com >:
>> > You may try using iterselect() instead of select() if the issue is
>> memory
>> > related.
>> >
>> > The link to the book is below.
>> >
>> >
>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=Using-an-iterator-based-select-for-lower-memory-use#Using-an-iterator-based-select-for-lower-memory-use
>>
>> >
>> > On Thursday, August 4, 2016 at 10:35:13 AM UTC+3, goome wrote:
>> >>
>> >> 2016-08-04 1:08 GMT+02:00, Dave S :
>> >> >
>> >> >
>> >> > On Wednesday, August 3, 2016 at 2:33:35 PM UTC-7, goome wrote:
>> >> >>
>> >> >> when trying in the shell, the shell itself got killed :
>> >> >> >> In [4]: legacy_db(query).select()
>> >> >> >>
>> >> >> >> Killed
>> >> >> >> root@rb:/home/www-data/web2py#
>> >> >>
>> >> >>
>> >> > Is that using web2py in a bash/python shell  (i.,e., -M -S myapp) ?
>> >> yes, this one
>> >>
>> >
>> > --
>> > 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 a topic in the
>> > Google Groups "web2py-users" group.
>> > To unsubscribe from this topic, visit
>> > https://groups.google.com/d/topic/web2py/nqUnVx62GE0/unsubscribe.
>> > To unsubscribe from this group and all its topics, send an email to
>> > web2py+un...@googlegroups.com .
>> > For more options, visit https://groups.google.com/d/optout.
>> >
>>
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/nqUnVx62GE0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] TAG helper and unnamed argument

2016-08-29 Thread Kirill Shatalaev

So, how to do some like:

1 day ago


I tried:


TAG.time('1 day ago', _pubdate=True,
 _datetime=str(datetime.year) + '-' + '%02d' % datetime.month + '-' + '%02d' % 
datetime.day)


And got:


1 day ago


Here I can read:

http://www.web2py.com/init/simple_examples/hello5


"attributes without value like "READONLY" can be created with the argument 
"_readonly=ON"."


But not _pubdate=True, nor _pubdate=ON (wich is deprecated and just an alias 
for True according to chapter 5) does not work for me and generates 
pubdate="pubdate".






-- 
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] custom update form multiple tables and list:string

2016-08-29 Thread Yoel Benitez Fonseca
h!

i got 2 tables, i need to make one update form for both, let's say they are:

-
db.define_table("item",
...
Field('keywords', 'list:string', ...)
...
)
db.define_table('concrete_item',
Field('item_id', 'reference item'),
...
)
-
In the controller:
-
def edit():
item = db.item(request.args(0))
concrete_item = db.concrete_item(item_id=item.id)
fields = []
for f in item:
fields.append(f)
for f in concrete_item:
fields.append(f)

form = SQLFORM.factory(*fields)
# put values to form fields
for f in db.item:
   form.vas[f.name] = item[f.name]
for f in db.concrete_item:
   form.vas[f.name] = item[f.name]

if form.proccess().accepted:
# here call update_record, etc.
pass

return dict(form=form)
-

The problem is with the keywords field, when the form is rendered in the
view it don't show the current value for the field. Meanwhile if i just
make the update form for only one table:


def edit()
item = db.item(request.args(0))

form = SQLFORM.factory(db.item, record=item)
return dict(form=form)


The keywords field show the current values. Can any1 help me with this ?

-- 
Yoel Benítez Fonseca
http://redevil.cubava.cu/
$ python -c "import this"

-- 
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: SQL10007N Message "0" could not be retrieved. Reason code: "3"

2016-08-29 Thread Dave S


On Sunday, August 28, 2016 at 5:41:16 PM UTC-7, elvis_x wrote:
>
> Hi All.
>
> I have a big problem to connect to my DB2 with nginx+uwsgi+web2py.
> everything works fine via "python web2py.py -p 8080"
>
> If start my Webpage,i get this error:
>
> Error ticket for "init"
> Ticket ID
>
> 127.0.0.1.2016-08-26.04-58-56.762c9daf-b362-412c-a0e5-8597f467f3a0
>  Failure to connect, tried 5 times: 
> Traceback (most recent call last): File 
> "/var/www/web2py/gluon/packages/dal/pydal/base.py", line 437, in __init__ 
> self._adapter = ADAPTERS[self._dbname](**kwargs) File 
> "/var/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 57, in 
> __call__ obj = super(AdapterMeta, cls).__call__(*args, **kwargs) File 
> "/var/www/web2py/gluon/packages/dal/pydal/adapters/db2.py", line 93, in 
> __init__ if do_connect: self.reconnect() File 
> "/var/www/web2py/gluon/packages/dal/pydal/connection.py", line 104, in 
> reconnect self.connection = f() File 
> "/var/www/web2py/gluon/packages/dal/pydal/adapters/db2.py", line 88, in 
> connector return self.driver.connect(cnxn, **driver_args) Error: (' ', '[ ] 
> [unixODBC][IBM][CLI Driver] SQL10007N Message "0" could not be retrieved. 
> Reason code: "3".\n (-1390) (SQLDriverConnect)') 
>
> Can help someone ?
>
> Thanks!
>
>
What does your connect statement look like?

/dps
 

-- 
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.


Re: [web2py] Re: DAL size limit for query?

2016-08-29 Thread Dave S


On Saturday, August 27, 2016 at 3:29:58 AM UTC-7, goome wrote:
>
> thank you for your answer and sorry for the delay, i had been some days 
> away. 
>
> at this time the code that fails is: 
> tabella = request.args[0] 
> response.headers['Content-Type']='text/x-csv' 
> response.headers['Content-Disposition']='attachment;filename="report.csv" 
> ' 
> dati = legacy_db().select(legacy_db[tabella].ALL) 
> s = cStringIO.StringIO() 
> dati.export_to_csv_file(s) 
>
>
> so i should use iterselect when defining dati, but when i try something 
> like: 
> """ 
> for row in legacy_db(legacy_db.COD2.id > 0).iterselect(): 
>: rtn = row 
>: 
> "" 
> i get : 
> "" 
> --- 
>
> AttributeErrorTraceback (most recent call 
> last) 
> /home/www-data/web2py/applications/PROVE/models/menu.py in () 
> > 1 for row in legacy_db(legacy_db.COD2.id > 0).iterselect(): 
>   2 rtn = row 
>   3 
>
> AttributeError: 'Set' object has no attribute 'iterselect' 
>
> "" 
>


You may need to show us your define_table statement(s), but it looks like 
you're writing down a query object and asking for iterselect on it, as in 
the book example.  One of the DB gurus may be needed.
 

> moreover, i should 'append' the row to a pydal.objects.Rows 
> as to say 
> dati += row 
> but how can i do this? 
>
>
That one looks easy:  data.append(row)
 

> Thank you a lot again 
>
>
Good luck!

/dps
 

>
> 2016-08-04 9:52 GMT+02:00, c...@cemeren.com  <
> c...@cemeren.com >: 
> > You may try using iterselect() instead of select() if the issue is 
> memory 
> > related. 
> > 
> > The link to the book is below. 
> > 
> > 
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=Using-an-iterator-based-select-for-lower-memory-use#Using-an-iterator-based-select-for-lower-memory-use
>  
> > 
> > On Thursday, August 4, 2016 at 10:35:13 AM UTC+3, goome wrote: 
> >> 
> >> 2016-08-04 1:08 GMT+02:00, Dave S : 
> >> > 
> >> > 
> >> > On Wednesday, August 3, 2016 at 2:33:35 PM UTC-7, goome wrote: 
> >> >> 
> >> >> when trying in the shell, the shell itself got killed : 
> >> >> >> In [4]: legacy_db(query).select() 
> >> >> >> 
> >> >> >> Killed 
> >> >> >> root@rb:/home/www-data/web2py# 
> >> >> 
> >> >> 
> >> > Is that using web2py in a bash/python shell  (i.,e., -M -S myapp) ? 
> >> yes, this one 
> >> 
> > 
> > -- 
> > 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 a topic in the 
> > Google Groups "web2py-users" group. 
> > To unsubscribe from this topic, visit 
> > https://groups.google.com/d/topic/web2py/nqUnVx62GE0/unsubscribe. 
> > To unsubscribe from this group and all its topics, send an email to 
> > web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
> > 
>

-- 
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: new to python web2py

2016-08-29 Thread billmackalister
May be try this?

def f1(f,v):
widget = SQLFORM.widgets.string.widget(f,v,_placeholder='descripción'), 
return locals()

Field("Description", "text", label='alguna 
cosa',requires=IS_NOT_EMPTY(),default=None,widget = f1),




On Sunday, August 28, 2016 at 10:00:55 PM UTC-4, Anthony wrote:
>
> def f1(field,value):
>> 
>> SQLFORM.widgets.string.widget(field,value,_placeholder='descripción'), 
>>
>> Works.
>> Field("Description", "text", label='alguna 
>> cosa',requires=IS_NOT_EMPTY(),default=None, lambda f,v: 
>> SQLFORM.widgets.string.widget(f, v, _placeholder='descripción')),
>>
>>
>> But no.
>> Field("Description", "text", label='alguna 
>> cosa',requires=IS_NOT_EMPTY(),default=None, f1(field,value)),
>>
>
> The widget argument must be a callable object (e.g., a function). However, 
> in your last line, you use f1(field, value), which is not a function but an 
> attempt to call the f1 function (with two variables that have not been 
> defined at this point). Instead, just use widget=f1.
>
> Anthony
>

-- 
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.


Re: [web2py] Re: Preceding backslash when using URL in ubuntu 16.04

2016-08-29 Thread Richard Vézina
You should consider using the script to properly install web2py :
https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh

You can then work from this basic installation to secure it better and fine
tune performance, configure proper database, etc.

Richard

On Mon, Aug 29, 2016 at 8:59 AM, Mirek Zvolský  wrote:

> Hi,
> Web2py (I think) at this time has no pip/PyPI packaging and no
> Debian/Ubuntu packaging. All previous attempts are obsolete.
>
> In Debian apt (Jessie testing) apt I see python-web2py version 2.12.3-1.
> But we have 2.14.6 at web2py.com, Download.
>
> I think you should switch to current version, using manual install
> (Download, Normal users, Source code).
> Unzip to the web2py/ folder and run from it: python web2py.py
>
> In my Web2py (2.14.5) when I run: python web2py.py -a "password" -M -S
> welcome
> I will get:
>
> In [1]: URL('default', 'home', scheme=True, host=True)
> Out[1]: 'http://127.0.0.1:8000/codex2020/default/home'
>
> In [2]: URL('default', 'home', scheme=True, host=False)
> Out[2]: '/codex2020/default/home'
>
> In [3]: URL('default', 'home', scheme=False, host=False)
> Out[3]: '/codex2020/default/home'
>
> In [4]: URL('default', 'home', scheme=False, host=True)
> Out[4]: 'http://127.0.0.1:8000/codex2020/default/home'
>
> So it looks like there is some issue with scheme= (has no efect), but not
> the issue that you describe.
>
>
>
> Dne pondělí 29. srpna 2016 2:41:17 UTC+2 Ryan Herbert napsal(a):
>
>> Hi, I'm having an issue with generating url with the URL helper.
>>
>> URL('default', 'home', scheme=True, host=True) will generate "\
>> https://127.0.0.1/myapp/default/home;
>>
>> I am using web2py from the python-web2py package from the ubuntu (or
>> debian?) repos. Now I also have my app installed on a server running Ubuntu
>> 14.04 and it works fine.
>> Does anyone know where this can come from ? I've been assuming I
>> configured my app incorrectly after upgrading to 16.04, but I can't seem to
>> find any issues with my configuration.
>>
>> Any advice is much appreciated.
>> Cheers,
>>
>> Ryan
>>
> --
> 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.
>

-- 
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: Is 'Container' a Reserved Word?

2016-08-29 Thread Anthony
There should be no problem spreading your table definitions over multiple 
model files. However, the db object itself must be defined in a model file 
that is executed *before* any other model files in which tables are 
defined. You could name that model file something like 0.py to ensure it 
runs before any other model files (model files are executed in alphabetical 
order).

Anthony

On Monday, August 29, 2016 at 8:47:39 AM UTC-4, Brian Boatright wrote:
>
> Thanks Anthony!
>
> All the db tables were defined in separate model files, which is what I 
> would prefer, but as a last attempt to resolve the conflict I moved them 
> all to a single models.py model file and arranged a few of the declarations 
> to avoid that error. It is working now but I would have preferred the 
> models in separate files, but maybe that's not possible when they have so 
> many foreign keys. 
>
> Is it possible to stage the order which the model files are read so table 
> declarations will be in the right sequence
>

-- 
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: one to many joins repeated parent

2016-08-29 Thread Mirek Zvolský
btw:

your tables aren't large, but small.
This will run well with SQLite on every hosting.

Example:

- Google App Engine NoSQL for free (with list:string fields for modificator)

- Forpsi virtual server 20G SSD with Postgres (or just SQLite)
http://www.forpsi.com/virtual/?lang=en-US
for 1.2 EUR/month,
install Debian (or something different) via VPS administration, run ssh, 
install nginx+postgres via apt - and go.
Or this should install nginx+Web2py on 
Debian: 
https://github.com/zvolsky/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh

I write that just because you say Amazon EC2 is too expensive(?)



Dne neděle 28. srpna 2016 23:21:31 UTC+2 luis.va...@metamaxzone.com 
napsal(a):
>
> Hello!
>
> I've this data structure in my database: i've two tables events and 
> modificators, one event can have many modificators so i've a one to many 
> relation. Im trying to build an HTTP endpoint that returns a json with 
> multiple events and all the asociated modificators, i order to do this i do 
> a join and return the select as a list, but my problem (and i understand 
> this problem is related to the way SQL works) is that the parent is 
> repeating on every record, so i've an event A with four modificators B, C, 
> D and E i get something like this:
>
> [{"events": A, "modificator": B}, {"events": A, "modificator": C}, 
> {"events": A, "modificator": D}, {"events": A, "modificator": E}]
>
> instead of this i want something like
>
>  [{"events": A, "modificator": [B, C, D, E]}]
>
> i now i can do this with a for and creating my own custom dictionary, but 
> i think this problem will be repeated several times along the api im 
> developing because my database has multiple one to many relations so it 
> would be good to get some "generic" solution instead of creating a lot of 
> nested fors for each case, also i think is a little bit inefficient doing 
> it on this way.
>
> I was wondering if the DAL or web2py himself has some method for this, or 
> if you can recomend a external library because i thinks this is a fair 
> common case, even if you can give me some guidance to develop a common 
> class, or function for this problem.
>
> By the way,  i read this example in the web2py manual:
>
> >>> for person in db().select(db.person.ALL):
> print person.name
> for thing in person.thing.select():
> print '', thing.nameAlex
>  Boat
>  ChairBob
>  ShoesCarl
>
> but i think it doesnt fit my needs because of the high database I/O, im 
> deploying my app on EC2 (Amazon) and the databases instances have a really 
> high cost, this is combined with my database having a LOT of records (about 
> 2000 events and 5800 modificators) and growing.
>
>
> Thanks for any help or guidance you can provide!
>

-- 
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: one to many joins repeated parent

2016-08-29 Thread Mirek Zvolský
With pydal (ie. db=DAL()) you can get the records in 2 queries:
event = db(db.events.id == wish_event_id).select()
and event_modificators = db(db.modificator.events_id 
== wish_event_id).select()

then convert to the list:
event_modificators = [row for row in event_modificators]# item is whole 
row
or event_modificators = [row.modificator for row in event_modificators]   
 # item is one field only.


If modificator has just 1 field (+ 2nd id field),
then instead of solution with 2 tables you could use just 1 table with 
Field(..., type="list:string").
This has special support on Google App Engine NoSQL, but on any other SQL 
database (SQLite, Postgres) it is supported as 'text' with '|' separators 
inside. I think you will get a list immediately when asking for such field. 
And it is supported in SQLFORM() too to set 1+ modificators.





Dne neděle 28. srpna 2016 23:21:31 UTC+2 luis.va...@metamaxzone.com 
napsal(a):
>
> Hello!
>
> I've this data structure in my database: i've two tables events and 
> modificators, one event can have many modificators so i've a one to many 
> relation. Im trying to build an HTTP endpoint that returns a json with 
> multiple events and all the asociated modificators, i order to do this i do 
> a join and return the select as a list, but my problem (and i understand 
> this problem is related to the way SQL works) is that the parent is 
> repeating on every record, so i've an event A with four modificators B, C, 
> D and E i get something like this:
>
> [{"events": A, "modificator": B}, {"events": A, "modificator": C}, 
> {"events": A, "modificator": D}, {"events": A, "modificator": E}]
>
> instead of this i want something like
>
>  [{"events": A, "modificator": [B, C, D, E]}]
>
> i now i can do this with a for and creating my own custom dictionary, but 
> i think this problem will be repeated several times along the api im 
> developing because my database has multiple one to many relations so it 
> would be good to get some "generic" solution instead of creating a lot of 
> nested fors for each case, also i think is a little bit inefficient doing 
> it on this way.
>
> I was wondering if the DAL or web2py himself has some method for this, or 
> if you can recomend a external library because i thinks this is a fair 
> common case, even if you can give me some guidance to develop a common 
> class, or function for this problem.
>
> By the way,  i read this example in the web2py manual:
>
> >>> for person in db().select(db.person.ALL):
> print person.name
> for thing in person.thing.select():
> print '', thing.nameAlex
>  Boat
>  ChairBob
>  ShoesCarl
>
> but i think it doesnt fit my needs because of the high database I/O, im 
> deploying my app on EC2 (Amazon) and the databases instances have a really 
> high cost, this is combined with my database having a LOT of records (about 
> 2000 events and 5800 modificators) and growing.
>
>
> Thanks for any help or guidance you can provide!
>

-- 
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: Preceding backslash when using URL in ubuntu 16.04

2016-08-29 Thread Mirek Zvolský
Hi,
Web2py (I think) at this time has no pip/PyPI packaging and no 
Debian/Ubuntu packaging. All previous attempts are obsolete.

In Debian apt (Jessie testing) apt I see python-web2py version 2.12.3-1.
But we have 2.14.6 at web2py.com, Download.

I think you should switch to current version, using manual install 
(Download, Normal users, Source code).
Unzip to the web2py/ folder and run from it: python web2py.py

In my Web2py (2.14.5) when I run: python web2py.py -a "password" -M -S 
welcome
I will get:

In [1]: URL('default', 'home', scheme=True, host=True) 
Out[1]: 'http://127.0.0.1:8000/codex2020/default/home' 

In [2]: URL('default', 'home', scheme=True, host=False) 
Out[2]: '/codex2020/default/home' 

In [3]: URL('default', 'home', scheme=False, host=False) 
Out[3]: '/codex2020/default/home' 

In [4]: URL('default', 'home', scheme=False, host=True) 
Out[4]: 'http://127.0.0.1:8000/codex2020/default/home'

So it looks like there is some issue with scheme= (has no efect), but not 
the issue that you describe.



Dne pondělí 29. srpna 2016 2:41:17 UTC+2 Ryan Herbert napsal(a):
>
> Hi, I'm having an issue with generating url with the URL helper.
>
> URL('default', 'home', scheme=True, host=True) will generate "\
> https://127.0.0.1/myapp/default/home;
>
> I am using web2py from the python-web2py package from the ubuntu (or 
> debian?) repos. Now I also have my app installed on a server running Ubuntu 
> 14.04 and it works fine.
> Does anyone know where this can come from ? I've been assuming I 
> configured my app incorrectly after upgrading to 16.04, but I can't seem to 
> find any issues with my configuration.
>
> Any advice is much appreciated.
> Cheers,
>
> Ryan
>

-- 
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: Reddit clone source code?

2016-08-29 Thread Brian Boatright
https://github.com/mdipierro/web2py-recipes-source/tree/master/source/02_building_your_first_applications/03_building_a_reddit_clone

and the source code for the book is on github as well
https://github.com/mdipierro/web2py-recipes-source/tree/master/source

-- 
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: Is 'Container' a Reserved Word?

2016-08-29 Thread Brian Boatright
Thanks Anthony!

All the db tables were defined in separate model files, which is what I 
would prefer, but as a last attempt to resolve the conflict I moved them 
all to a single models.py model file and arranged a few of the declarations 
to avoid that error. It is working now but I would have preferred the 
models in separate files, but maybe that's not possible when they have so 
many foreign keys. 

Is it possible to stage the order which the model files are read so table 
declarations will be in the right sequence?

On Sunday, August 28, 2016 at 8:41:17 PM UTC-4, Brian Boatright wrote:
>
> I've tried adding a model for "Containers" and "ContainerTypes" each time 
> I get an error when it tries to create the tables when I click the Database 
> Admin button.
>
> The other tables I'm defining are working fine. I have a few other tables 
> that have "Type" in their mode/table name so when I couldn't create 
> "containers" table.
>
> I've looked at MySQL and MariaDB (which I'm using) and do not see 
> "container" or something similar listed as a reserved word. 
>
> here is the error
>
>  name 'db' is not defined
>
>
> db.define_table('containers',
> Field('parentid','reference containers'),
> Field('name','string'))
>
> *Traceback (most recent call last):*
>
>>   File "C:\dev\web2py\gluon\restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File "C:/dev/web2py/applications/partsbin/models/containers.py", line 
>> 2, in 
>> db.define_table('containers',
>> NameError: name 'db' is not defined
>
>

-- 
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: Help with Patterns

2016-08-29 Thread Anthony
You might also consider putting these parameters in a query string rather 
than the URL path. That way, you could simply exclude parameters that are 
not being used for a given query (in web2py, missing query string variables 
will simply have the value None -- for example, if you attempt to access 
request.vars.amount_range_id but it was not included in the requested URL, 
it will have the value None).

Anthony

On Sunday, August 28, 2016 at 8:41:16 PM UTC-4, Diego Marinho wrote:
>
> I have this pattern:
>
>
> "/jobs/year-start/{jobs.year_start.year}/amount-range-id/{jobs.amount_range_id}/neighbourhood-id/{jobs.neighbourhood_id}"
>
> I have tree fields that im using to filter the 'jobs' table. How can i 
> make those filters optional? 
>
> Let's say i want to use only two of the tree possible filters. What can i 
> send instead of the id to say that i want all data concerning that field?  
>

-- 
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: Help with Patterns

2016-08-29 Thread Niphlod
are you talking about a general idea for the api ? I'd use 'all' ...

On Monday, August 29, 2016 at 2:41:16 AM UTC+2, Diego Marinho wrote:
>
> I have this pattern:
>
>
> "/jobs/year-start/{jobs.year_start.year}/amount-range-id/{jobs.amount_range_id}/neighbourhood-id/{jobs.neighbourhood_id}"
>
> I have tree fields that im using to filter the 'jobs' table. How can i 
> make those filters optional? 
>
> Let's say i want to use only two of the tree possible filters. What can i 
> send instead of the id to say that i want all data concerning that field?  
>

-- 
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.


Re: [web2py] Re: I am trying to login from Phonegap app into my web2py app, what's wrong here?

2016-08-29 Thread Niphlod
technically though USERNAME is clear. so you need to query for username and 
just match the password with the crypted value.

On Monday, August 29, 2016 at 3:05:20 AM UTC+2, Massimo Di Pierro wrote:
>
> This cannot be done. It is a feature not a bug. The purpose of the salt in 
> the hashed password is to prevent brute force attacks to the database. What 
> you are doing is the brute force attack.
>
> The only way to do it is to select all records. Loop one by one and 
> compare them with 
>
> encpwd = 
> CRYPT(digest_alg='pbkdf2(1000,20,sha512)')(request.vars.password)[0])
> for row in db(..).select(): 
> if row.password == encpwd: 
>
> I guess this is a ever more brute force attack It will be slow but may 
> work on small databases.
>
>
>
>
> On Sunday, 28 August 2016 08:39:06 UTC-5, Steve Joe wrote:
>>
>> db((db.auth_user.username == request.vars.username) & 
>> (db.auth_user.password == 
>> CRYPT(digest_alg='pbkdf2(1000,20,sha512)')(request.vars.password)[0])).select()
>> this doesn't work at all too.
>>
>> On Saturday, August 27, 2016 at 5:44:53 PM UTC+5:30, Kiran Subbaraman 
>> wrote:
>>>
>>> The book can help you: 
>>> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Logical-operators
>>> You need to use the right operator in your query
>>> You can also use the web2py debugger to figure out how your code works 
>>> and values returned, at runtime.
>>>
>>> 
>>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/
>>>
>>> On Sat, 27-08-2016 2:50 PM, Steve Joe wrote:
>>>
>>> Anyone there? Anthony?
>>>
>>> On Friday, August 26, 2016 at 7:38:40 PM UTC+5:30, Steve Joe wrote: 

 *db(db.auth_user.username == request.vars.username and 
 db.auth_user.password == CRYPT(request.vars.password)).select()*


 *if db(db.auth_user.username == request.vars.username and 
 db.auth_user.password == 
 CRYPT(digest_alg='md5')(request.vars.password)[0]).select(): * 

 Both of them don't work either. 

 On Friday, August 26, 2016 at 7:30:41 PM UTC+5:30, Niphlod wrote: 
>
> fortunately the password doesn't get stored in plain text on web2py :D 
> You need to apply CRYPT() before comparing. Read more about that on the 
> book.
>
> On Friday, August 26, 2016 at 3:31:54 PM UTC+2, Steve Joe wrote: 
>>
>> IN PHONEGAP: 
>>
>> https://#someurl#.
>> pythonanywhere.com/welcome/phonegap/login">
>>   username:
>>   
>>   
>>   Password:
>>   
>>   
>>   
>> 
>>
>>
>> IN WEB2PY:
>>
>> def login():
>> k="false"
>> if db(db.auth_user.username == request.vars.username and 
>> db.auth_user.password == request.vars.password).select():
>> k="true"
>> return locals()
>>
>> and in view I can see:
>>
>>  false 
>> which means I got k as false.
>>
>> The username and pasword are correct according to my database but I 
>> can't login. What should I do?
>>
> -- 
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>

-- 
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: Recaptcha2 in custom form

2016-08-29 Thread 'Annet' via web2py-users
Hi Massimo,

Thanks for your reply, problem solved nicely.


Kind regards,

Annet

-- 
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.