[web2py] Re: Looking for a simple reservation system

2020-04-17 Thread Remco Boerma
Reviving a post of more than  a decade ago. 
Does anyone have an opensource web2py application available for 
booking/reservations like this? 
An old example was referenced but is no longer available. 

With kind regards, 
Remco Boerma 

Op woensdag 28 oktober 2009 01:38:23 UTC+1 schreef Brian M:
>
> Very cool. The non-profit I work for has been looking for a scheduling 
> system for volunteers and this may give us a start if we decide to do 
> our own. As others have said, every resource ends up with different 
> requirements - we for example would have pre-defined time slots that 
> can hold a limited number of people and then want group leaders to 
> reserve some number of slots and then individuals to register as part 
> of a group. Then add in families or individuals that aren't part of a 
> group but still want to help out and you get a jumbled mess of 
> requirements. We've looked at commercial systems and they all end up 
> being restrictive in some silly way. 
>
> One bug I noticed, the calendar display shows an event booked 
> 2009-10-28 18:00:00 to 2009-10-28 19:30 as happening all day both Oct 
> 28 & 29. Your strftime pattern is wrong in plugin_booking/ 
> calendar.html it should probably be .strftime('%B %d, %Y %H:%M:%S') 
> instead of .strftime('%B %d, %Y %M:%H:%S')  - you've got the hours and 
> minutes flipped. 
>
> On Oct 26, 11:21 pm, mdipierro  wrote: 
> > BTW. The total length is 40 lines of python code (models and 
> > controllers) on top of the scaffoding app + ~200 lines of custom html 
> > + fullcalendar.js and dependencies. 
> > 
> > On Oct 26, 11:17 pm, mdipierro  wrote: 
> > 
> > > Fixed and resposted. It works great and I think it does what people 
> > > asked. 
> > 
> > > - It may need a new more js effects. 
> > > - It certainly needs a better layout. 
> > > - It is all coded as a plugin (so you can add this to app that defines 
> > > db, auth, crud) 
> > > - You may want to add some more actions 
> > 
> > > It would be great if one of you were to adopt it and maintain it. 
> > 
> > > Massimo 
> > 
> > > On Oct 26, 10:45 pm, mdipierro  wrote: 
> > 
> > > > Can you help me with this? 
> > 
> > > >http://web2py.com/examples/static/web2py.app.booking.w2p 
> > 
> > > > Almost everything works except the jquery calendar widget does not 
> > > > display events. I do not know why. 
> > 
> > > > It would also be nice to add a better layout. 
> > 
> > > > Massimo 
> > 
> > > > On Oct 26, 8:02 pm, Thadeus Burgess  wrote: 
> > 
> > > > > It would be nice to have a simple scheduling / allocation 
> interface, that 
> > > > > could easily be extended. Provide a base system so that everyone 
> can add 
> > > > > their own requirements into it. 
> > 
> > > > > -Thadeus 
> > 
> > > > > On Mon, Oct 26, 2009 at 7:49 PM, Alex Fanjul <
> alex.fan...@gmail.com> wrote: 
> > > > > >  We have a requirement for system like this for a laboratory 
> with rooms and 
> > > > > > objets (machines, cubes, etc.) treated as shared resources, as 
> soon as I can 
> > > > > > I will send you the requirements. 
> > > > > > Alex F 
> > 
> > > > > > El 27/10/2009 1:06, david bain escribió: 
> > 
> > > > > > Just to extend the feature set, it would be nice if you could 
> 'register' 
> > > > > > and manage/present the bookings of multiple properties. 
> > 
> > > > > > On Mon, Oct 26, 2009 at 4:38 PM, villas  
> wrote: 
> > 
> > > > > >> We have a similar system requirement:  accommodation bookings. 
>  In 
> > > > > >> this case,  each room/property is booked for a flexible period 
> of 
> > > > > >> days.  As Weheh says,  in each type of resource booking system, 
>  there 
> > > > > >> are so many add-on requirements for each use case.  I believe 
> one of 
> > > > > >> the central features of an "excellent" system is making really 
> good 
> > > > > >> booking charts, so people can see availability at a glance. 
> > 
> > > > > > -- 
> > > > > > SplashStart - Professional Websites. Starting Now. 
> > > > > >http://www.splashstart.com 
> > 
> > > > > > -- 
> > > > > > Alejandro Fanjul Fdez. 
> > > > > > alex.fan...@gmail.com 
> > > > > >www.mhproject.org

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/14d89a17-2d90-427c-bbe2-13ec88b2c834%40googlegroups.com.


[web2py] Re: table already exists; 'Rows' object has no attribute 'fields'

2017-05-18 Thread Remco Boerma
Thanks for that. 

It does introduce a  new error: 

ValueError: Field student_record.request_tenant is already bound to a table


The latest pydal as db._common_fields don't seem to get along. 

db._common_fields.append(auth.signature)
db._common_fields.append(Field('request_tenant',
   default=user_org,
   writable=False))



Any ideas on that? 
Thanks. 

Op woensdag 19 april 2017 17:43:45 UTC+2 schreef Anthony:
>
> On Wednesday, April 19, 2017 at 4:24:21 AM UTC-4, Wabbajack wrote:
>>
>> Hi Dave,
>>
>> Thanks for the quick response..
>>
>> Yes i am using Windows also downloaded from GIT repository
>>
>
> It is possible you did not get the updated pydal because that is not part 
> of the web2py repository but a submodule. When doing the initial clone, you 
> need to add --recursive, and when updating, I think you need to run "git 
> submodule update".
>
> Also, when updating web2py, you should also update your application's 
> appadmin.py controller and appadmin.html view, in case any changes have 
> been made.
>
> 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.


[web2py] Re: SQLForm.grid csv export

2016-09-01 Thread Remco Boerma
Although it's been half a year; for the record, see this 
post: https://groups.google.com/d/msg/web2py/6W-jf3EPb04/x3hSC5ySCgAJ 

Op donderdag 28 juli 2016 10:17:50 UTC+2 schreef Ryan Hood:
>
> Hello,
>
>  
>
> I'm pretty new to Web2py.  I need some help with the SQLForm.grid export 
> CSV functionality.I have the following basic structure:
>
>  
>
> *db.py*
>
> db.define_table('test',
>
> Field('name', 'string', length=50, notnull=True),
>
> Field('email', 'string', notnull=True),
>
> format="%(name)s")
>
> *default.py*
>
> def index():
>
> query=(db.test.id>0)
>
> fields=[db.test.id,db.test.name,db.test.email]
>
> forms=SQLFORM.grid(query=query, csv=True)
>
> return dict(forms=forms)
>
>  
>
> For some reason only the JSON and XML exports work but the CSV and TSV 
> exports won't work.  For CSV, I keep getting the following error:
>
>  
>
> **
>
>  
>
> NOTE: my argument list looks like this: 
>
> *Function argument list*
>
> (self=, k='_extra')
>
>  
>
> NOTE: I have tried a couple different versions of Web2py on both CentOS 
> and Windows and same error.
>
>  
>
> I'm sure I'm missing something small, but haven't been able to track it 
> down.  Any help would be appreciated.
>
>  
>
> Thank you,
>
> 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] web2py in virtualenv

2016-05-25 Thread Remco Boerma
Hey folks. 

I want to use pydal and the validators of web2py in a virtualenv. I am 
working on a seperate script and not a full blown web2py application. So no 
web, just console. 
Since pip install web2py produces nothing useful i do this: 

cd env
bin/activate
cd lib/site-packages
git clone https://github.com/web2py/web2py
echo '' > web2py/__init__.py


In  the python script i can now do the following: 

import sys, os.path , web2py

from pydal import DAL , Field

w2p_folder, _ = os.path.split(web2py.__file__) 


sys.path.extend((w2p_folder, os.path.join(w2p_folder,'gluon')))
from gluon.validators import IS_IN_DB
db = DAL('sqlite://somedb_effdt.db')


It works, but it feels dirty. Some parts of web2py need direct access to 
gluon and others to the packages inside gluon. 
Anyone have a cleaner working solution or would this be as good as it gets? 
 
Regards, 
Remco Boerma

-- 
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: web2py and python3

2015-11-23 Thread Remco Boerma
I've done my homework and agree Massimo. There is hardly a thing that 
requires python3 that doesn't work with python2. The only one i know 
is https://micropython.org/ but it's not a big company, nor a "big" 
product. 


Op woensdag 11 november 2015 16:21:18 UTC+1 schreef Massimo Di Pierro:
>
> As of today python 3 is used almost exclusively in schools. Do you know of 
> any large company that uses Python 3? I do not. But I know many large 
> companies that use Python 2, including banks.  
>
> On Monday, 9 November 2015 01:36:40 UTC-6, Remco Boerma wrote:
>>
>> Great one Alex. 
>>
>> While searching for web2py and python3 the first result i got was this 
>> <https://www.reddit.com/r/Python/comments/31ai10/web2py_python3/>. 
>>  
>>
>>> Hi...I m total beginner in python with elastic search also Unicode ... I 
>>> am looking for a wonderful framework & was keen on web2py..but just 
>>> happened to read that its not compatible with python 3..
>>>
>>> Pl guide me abt this issue & in selecting framework
>>>
>>> With regards to all,
>>>
>>
>> I've been asked to start a new internship-company for a project i'm 
>> involved in. And I so want to take those boys and girls on the web2py path, 
>> but to ask of those new-to-the-market to invest in a legacy language (2020 
>> is only 4 years from now) is something that feels odd to me. Especially 
>> since i know the power and grace of web2py. 
>>
>> I know the subject has been debated and debated but for the sake of these 
>> students (and these are not the high university kind, but rather the 
>> ground-work and getting-stuff-done folks) i would kindly ask to take the 
>> future into consideration as well as our marketing because web2py is simply 
>> droped out of the equation because of py2. I would love to teach those kids 
>> web2py and be future proof. Many schools already teach things from a 
>> hundred years ago, let's not do that in IT as well. 
>>
>> Thank your for considering. 
>>
>> Op vrijdag 6 november 2015 23:57:33 UTC+1 schreef Alex:
>>>
>>> web2py for python 3 would be great. I hope it comes rather sooner than 
>>> later. I'd love to use python 3, no more str <-> unicode nonsense (which 
>>> already caused many issues and wasted time for me), type hints (seems to 
>>> have good support in PyCharm) and other new features. I think the current 
>>> situation could also scare away potential new users when they see that 
>>> web2py does not support python 3.
>>>
>>> pyDAL seems to be already compatible with python 3. Is it not possible 
>>> to make the remaining parts also compatible or are there completely new 
>>> concepts planned? I for one would completely remove the FORM code - it's 
>>> nice and easy to get something up and running but difficult to style (no 
>>> clear separation of backend/frontend) and extend. I'm using knockout (I 
>>> guess any data binding js lib will do fine) which is very flexible and easy 
>>> to understand. That should be the preferred way to do forms and recommended 
>>> in the book. But that's just my opinion. No more FORM would mean less code 
>>> to port to python 3 ;)
>>>
>>> Alex
>>>
>>> On Wednesday, November 4, 2015 at 4:37:56 PM UTC+1, Ramos wrote:
>>>>
>>>> @massimo 
>>>> When will it be available ? 
>>>>
>>>>
>>>> 2015-11-04 14:38 GMT+00:00 Massimo Di Pierro <massimo@gmail.com>:
>>>>
>>>>> There will be a new framework similar to web2py for python 3. web2py 
>>>>> has to be backward compatible and it is pointless to port it to python 3. 
>>>>>
>>>>>
>>>>> On Wednesday, 4 November 2015 06:25:40 UTC-6, Jim Gregory wrote:
>>>>>>
>>>>>> I know this has come up in the past, but it hasn't been asked in a 
>>>>>> while. 
>>>>>>
>>>>>> Is there ever going to be a usable and maintained Python3-compatible 
>>>>>> fork of web2py?
>>>>>>
>>>>>> The latest edition of Fedora now ships with Python3 by default. It's 
>>>>>> the default version used in Django's tutorial.
>>>>>>
>>>>>> I'm not using Python3 now, but I can see the day when I inevitably 
>>>>>> will. I don't want to invest the time in a framework if I know I'll have 
>>>>>> to 
>>>>>> abandon it

Re: [web2py] Re: web2py and python3

2015-11-08 Thread Remco Boerma
Great one Alex. 

While searching for web2py and python3 the first result i got was this 
. 
 

> Hi...I m total beginner in python with elastic search also Unicode ... I 
> am looking for a wonderful framework & was keen on web2py..but just 
> happened to read that its not compatible with python 3..
>
> Pl guide me abt this issue & in selecting framework
>
> With regards to all,
>

I've been asked to start a new internship-company for a project i'm 
involved in. And I so want to take those boys and girls on the web2py path, 
but to ask of those new-to-the-market to invest in a legacy language (2020 
is only 4 years from now) is something that feels odd to me. Especially 
since i know the power and grace of web2py. 

I know the subject has been debated and debated but for the sake of these 
students (and these are not the high university kind, but rather the 
ground-work and getting-stuff-done folks) i would kindly ask to take the 
future into consideration as well as our marketing because web2py is simply 
droped out of the equation because of py2. I would love to teach those kids 
web2py and be future proof. Many schools already teach things from a 
hundred years ago, let's not do that in IT as well. 

Thank your for considering. 

Op vrijdag 6 november 2015 23:57:33 UTC+1 schreef Alex:
>
> web2py for python 3 would be great. I hope it comes rather sooner than 
> later. I'd love to use python 3, no more str <-> unicode nonsense (which 
> already caused many issues and wasted time for me), type hints (seems to 
> have good support in PyCharm) and other new features. I think the current 
> situation could also scare away potential new users when they see that 
> web2py does not support python 3.
>
> pyDAL seems to be already compatible with python 3. Is it not possible to 
> make the remaining parts also compatible or are there completely new 
> concepts planned? I for one would completely remove the FORM code - it's 
> nice and easy to get something up and running but difficult to style (no 
> clear separation of backend/frontend) and extend. I'm using knockout (I 
> guess any data binding js lib will do fine) which is very flexible and easy 
> to understand. That should be the preferred way to do forms and recommended 
> in the book. But that's just my opinion. No more FORM would mean less code 
> to port to python 3 ;)
>
> Alex
>
> On Wednesday, November 4, 2015 at 4:37:56 PM UTC+1, Ramos wrote:
>>
>> @massimo 
>> When will it be available ? 
>>
>>
>> 2015-11-04 14:38 GMT+00:00 Massimo Di Pierro :
>>
>>> There will be a new framework similar to web2py for python 3. web2py has 
>>> to be backward compatible and it is pointless to port it to python 3. 
>>>
>>>
>>> On Wednesday, 4 November 2015 06:25:40 UTC-6, Jim Gregory wrote:

 I know this has come up in the past, but it hasn't been asked in a 
 while. 

 Is there ever going to be a usable and maintained Python3-compatible 
 fork of web2py?

 The latest edition of Fedora now ships with Python3 by default. It's 
 the default version used in Django's tutorial.

 I'm not using Python3 now, but I can see the day when I inevitably 
 will. I don't want to invest the time in a framework if I know I'll have 
 to 
 abandon it later.

>>> -- 
>>> 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: IIS 8.5 static file using rewrite problem

2015-08-18 Thread Remco Boerma
I've uploaded a video demonstrating the installation I did which works 
quite well. it's far from perfect as a video and demonstration, but all the 
tinkering is in there, i think it matches your setup quite well.  

https://www.youtube.com/watch?v=gxOhsThD0FY 

Op dinsdag 18 augustus 2015 10:43:55 UTC+2 schreef Niphlod:

 didn't quite get if it's an error on the recipe (which I can't replicate, 
 since it's my standard tried several times setup) or your slightly changed 
 recipe was the cause of the error.

 On Tuesday, August 18, 2015 at 10:07:21 AM UTC+2, Remco Boerma wrote:

 Solved. 

 While gathering information about my setup I found the solution. 

 Setting Default web site  Authentication  Anonymous Authentication 
 (keep enabled)  to Application Pool Identity solved my issue. 



 Here's a few tags and keywords for future reference when someone else 
 bumps into this: 

 In IIS i have one site, which is the default web site. It's stored at 
 c:/inetpub/wwwroot. This is where the web2py zip file contents went, so 
 there is an applications folder, examples, gluon, jada jada. URL rewrite is 
 used like in the example given in the web2py book. 
 When the static rewrite rule is enabled and setting error pages  Edit 
 feature settings Detailed errors I  get the following error when 
 requesting http://wvwebt01/welcome/static/css/calendar.css:


 HTTP Error 401.3 - Unauthorized
 You do not have permission to view this directory or page because of the 
 access control list (ACL) configuration or encryption settings for this 
 resource on the Web server.

 Detailed Error Information:
 Module   IIS Web Core
 Notification   AuthenticateRequest
 Handler   StaticFile
 Error Code   0x80070005
 Requested URL   
 http://wvwebt01:80/applications/welcome/static/css/calendar.css
 Physical Path   
 C:\inetpub\wwwroot\applications\welcome\static\css\calendar.css
 Logon Method   Anonymous
 Logon User   Anonymous

 Looking at http://stackoverflow.com/a/10457630 i changed iis manager 
 default web site  authentication  Anonymous Authentication  Edit...  to 
 Application pool identity instead of specific user: IUSR (which is the 
 default). Since this user is not given any direct access on the files, but 
 following the books recipe the  application pool group is. (
 http://www.web2py.com/books/default/chapter/29/13/deployment-recipes#IIS
 ) 

 Thanks anyway Niphlod!

 Op donderdag 13 augustus 2015 15:03:34 UTC+2 schreef Niphlod:

 401 means not authorized. What happens without rewrite (or incorrect 
 ones) is usually 404 (not found) . 
 Can you post more details about the structure of the iis site which the 
 app belongs ?

 On Wednesday, August 12, 2015 at 6:01:45 PM UTC+2, Remco Boerma wrote:

 Hi, 

 I'm migrating from ubuntu to windows 2012R2 + IIS 8.5. 

 Following a slightly altered recipe from the book to install web2py 
 under IIS (but mostly the same) i've come across a strange error. Since 
 i'm 
 not accustomed to IIS, it can well be my issue is standard 
 IIS-knowledge-gap related. I have installed the rules module, have web2py 
 up and running. Now i installed another app inside web2py that worked 
 before on a 2.11.2 on my local windows machine as well as on a 2.9.5 
 server 
 behind apache and all of a sudden my static files are 401'd 

 I don't use any special static versioning. When i disabled the static 
 rewrite rule everything works like a charm. My setup is as simple as 
 possible (only web2py in the root) running 2.12.2 stable on ii 8.5 python 
 2.7.9. 

 the static rule in web.config (comes from the sample) is: 

 rule name=static enabled=false stopProcessing=true match 
 url=^(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ / conditions 
 logicalGrouping=MatchAll trackAllCaptures=false / action 
 type=Rewrite url=applications/{R:1}/static/{R:2} 
 logRewrittenUrl=false / /rule

 Does anyone have any clue why i have those 401s? 


 With kind regards, 
 Remco Boerma




-- 
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: IIS 8.5 static file using rewrite problem

2015-08-18 Thread Remco Boerma
Solved. 

While gathering information about my setup I found the solution. 

Setting Default web site  Authentication  Anonymous Authentication (keep 
enabled)  to Application Pool Identity solved my issue. 



Here's a few tags and keywords for future reference when someone else bumps 
into this: 

In IIS i have one site, which is the default web site. Below It's stored at 
c:/inetpub/wwwroot. This is where the web2py zip file contents went, so 
there is an applications folder, examples, gluon, jada jada. URL rewrite is 
used like in the example given in the web2py book. 
When the static rewrite rule is enabled and setting error pages  Edit 
feature settings Detailed errors I  get the following error when 
requesting http://wvwebt01/welcome/static/css/calendar.css:


HTTP Error 401.3 - Unauthorized
You do not have permission to view this directory or page because of the 
access control list (ACL) configuration or encryption settings for this 
resource on the Web server.

Detailed Error Information:
Module   IIS Web Core
Notification   AuthenticateRequest
Handler   StaticFile
Error Code   0x80070005
Requested URL   
http://wvwebt01:80/applications/welcome/static/css/calendar.css
Physical Path   
C:\inetpub\wwwroot\applications\welcome\static\css\calendar.css
Logon Method   Anonymous
Logon User   Anonymous

Looking at http://stackoverflow.com/a/10457630 i changed iis manager 
default web site  authentication  Anonymous Authentication  Edit...  
Application pool identity instead of specific user IUSR (default), which 
is not given any direct access on the files, but according to the book the 
application pool group is. 

Thanks Niphlod!

Op donderdag 13 augustus 2015 15:03:34 UTC+2 schreef Niphlod:

 401 means not authorized. What happens without rewrite (or incorrect ones) 
 is usually 404 (not found) . 
 Can you post more details about the structure of the iis site which the 
 app belongs ?

 On Wednesday, August 12, 2015 at 6:01:45 PM UTC+2, Remco Boerma wrote:

 Hi, 

 I'm migrating from ubuntu to windows 2012R2 + IIS 8.5. 

 Following a slightly altered recipe from the book to install web2py under 
 IIS (but mostly the same) i've come across a strange error. Since i'm not 
 accustomed to IIS, it can well be my issue is standard IIS-knowledge-gap 
 related. I have installed the rules module, have web2py up and running. Now 
 i installed another app inside web2py that worked before on a 2.11.2 on my 
 local windows machine as well as on a 2.9.5 server behind apache and all of 
 a sudden my static files are 401'd 

 I don't use any special static versioning. When i disabled the static 
 rewrite rule everything works like a charm. My setup is as simple as 
 possible (only web2py in the root) running 2.12.2 stable on ii 8.5 python 
 2.7.9. 

 the static rule in web.config (comes from the sample) is: 

 rule name=static enabled=false stopProcessing=true match 
 url=^(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ / conditions 
 logicalGrouping=MatchAll trackAllCaptures=false / action 
 type=Rewrite url=applications/{R:1}/static/{R:2} 
 logRewrittenUrl=false / /rule

 Does anyone have any clue why i have those 401s? 


 With kind regards, 
 Remco Boerma




-- 
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] IIS 8.5 static file using rewrite problem

2015-08-12 Thread Remco Boerma
Hi, 

I'm migrating from ubuntu to windows 2012R2 + IIS 8.5. 

Following a slightly altered recipe from the book to install web2py under 
IIS (but mostly the same) i've come across a strange error. Since i'm not 
accustomed to IIS, it can well be my issue is standard IIS-knowledge-gap 
related. I have installed the rules module, have web2py up and running. Now 
i installed another app inside web2py that worked before on a 2.11.2 on my 
local windows machine as well as on a 2.9.5 server behind apache and all of 
a sudden my static files are 401'd 

I don't use any special static versioning. When i disabled the static 
rewrite rule everything works like a charm. My setup is as simple as 
possible (only web2py in the root) running 2.12.2 stable on ii 8.5 python 
2.7.9. 

the static rule in web.config (comes from the sample) is: 

rule name=static enabled=false stopProcessing=true match 
url=^(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ / conditions 
logicalGrouping=MatchAll trackAllCaptures=false / action 
type=Rewrite url=applications/{R:1}/static/{R:2} 
logRewrittenUrl=false / /rule

Does anyone have any clue why i have those 401s? 


With kind regards, 
Remco Boerma


-- 
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: IMPORTANT - WEB2PY CONSULTING

2015-04-08 Thread Remco Boerma

Please add http://www.dutveul.nl (Netherlands) to the list. 

The site itself is web2py and a few solutions i'm working on now are web2py 
based solutions. Only recently i started my ICT job as self-employed 
part-time. Will add a web2py specific page in the near future. 

Regards, 
Remco 

-- 
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] How to use DAL with effective dated queries

2014-12-08 Thread Remco Boerma
Resurrecting an old question... 

Below is my attempt to perform an effective dated DAL based query, the 
results and what i would like to be executed.  

Basically given a table with both an effective date (effdt) and an 
identifier (i) i want to use a query so i have only one round trip to the 
database that returns the currently effective row (the last row for the 
given identifier in the past). Such a query is given below, now i want to 
create it using the DAL. 


def test2():
dbtest = DAL('sqlite:memory:')
dbtest.define_table('a',Field('i','integer'), Field('name','string'), 
Field('effdt','datetime'))
dbtest.a.insert(i=1, name='Bob', effdt = 
request.now+datetime.timedelta(days=-3))
dbtest.a.insert(i=1, name='Bobbel', effdt = 
request.now+datetime.timedelta(days=-2))
dbtest.a.insert(i=2, name='Ed', effdt = 
request.now+datetime.timedelta(days=-1))
dbtest.a.insert(i=2, name='Eduard', effdt = request.now)
dbtest.a.insert(i=2, name='Eddy', effdt = 
request.now+datetime.timedelta(days=1))
base =  BEAUTIFY(dbtest(dbtest.a).select())
outer = dbtest.a.with_alias('out')
ed = dbtest.a.with_alias('ed')
max_from_ed = dbtest(outer.i == ed.i)._select(ed.effdt.max())
result = dbtest(outer.effdt.belongs(max_from_ed)  (outer.i == ed.i)  
(ed.effdt = request.now)).select(outer.ALL)
a1 = BEAUTIFY(result)
b = dbtest._lastsql
result = dbtest.executesql('select out.* from a out where out.effdt = 
(select max(ed.effdt) from a as ed where out.i = ed.i and ed.effdt = 
?)',placeholders=(request.now,))
c = dbtest._lastsql
a2 = BEAUTIFY(result)
return '\nhr\n'.join([str(base),str(a1),b,str(a2),c])


The results, in order: the table as in memory, the results using my wrong 
dal query, the dal produced sql, my raw sql results and my raw sql 
statement: 

a.id

a.i

a.name

a.effdt

1

1

Bob

2014-12-05 13:23:52

2

1

Bobbel

2014-12-06 13:23:52

3

2

Ed

2014-12-07 13:23:52

4

2

Eduard

2014-12-08 13:23:52

5

2

Eddy

2014-12-09 13:23:52

--
out.idout.iout.nameout.effdt52Eddy2014-12-09 13:23:5252Eddy2014-12-09 
13:23:52
--
SELECT out.id, out.i, out.name, out.effdt FROM a AS ed, a AS out WHERE 
(((out.effdt IN (SELECT MAX(ed.effdt) FROM a AS ed, a AS out WHERE (out.i = 
ed.i))) AND (out.i = ed.i)) AND (ed.effdt = '2014-12-08 13:23:52'));
--
21Bobbeldatetime.datetime(2014, 12, 6, 13, 23, 
52)42Eduarddatetime.datetime(2014, 
12, 8, 13, 23, 52)
--
select out.* from a out where out.effdt = (select max(ed.effdt) from a as 
ed where out.i = ed.i and ed.effdt = ?)


The last query is what i want to achieve in the DAL. As you can see i have 
the issue with the aliases being thrown-in in both the outer and inner 
query. 
This is the formatted query the DAL produces: 

SELECT out.id,
   out.i,
   out.name,
   out.effdt
FROM a AS ed,
 a AS OUT
WHERE (((OUT.effdt IN
   (SELECT MAX(ed.effdt)
FROM a AS ed,
 a AS OUT
WHERE (OUT.i = ed.i)))
AND (OUT.i = ed.i))
   AND (ed.effdt = '2014-12-08 13:23:52'));

and this is what my own query looks like: 

SELECT out.*
FROM a OUT
WHERE OUT.effdt =
(SELECT max(ed.effdt)
 FROM a AS ed
 WHERE OUT.i = ed.i
   AND ed.effdt = ?)

I would really appreciate any help on a DAL only solution that results in 
the latter query being executed. 

With kind regards, 
Remco Boerma

-- 
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] How to use DAL with effective dated queries

2014-12-08 Thread Remco Boerma
Thanks, i'll checkout the lateral joins. :) 

In the case of the clean API, the sql i produced is SQL-92 compatible, is 
that  clean enough? :) As for iterating over the results in python doesn't 
seem like an all to valid option with some larger tables. (We use 
Peoplesoft HR with years of history resulting in tables with millions of 
rows like this) - Think i will stick to crafted SQL for now! 

Remco



Op maandag 8 december 2014 19:20:20 UTC+1 schreef Niphlod:

 given that the aliases are not supported in master-sub selects (i.e. 
 they're coded with the same level of aliasing in mind, whereas your 
 select needs to propagate a carefully crafted alias in some place), the 
 problem relies on the fact that subselect are only allowed to have multiple 
 conditions to be specified. 
 Moreover, what you're actually lacking (or, from another perspective, DAL 
 is lacking) is access to window functions
 In this particular case it's not needed, and you could ,e.g., use a Set to 
 specify a two-column resultset that needs to be matched with another table 
 to give you the result, we'll be ok The first set would be a (emp_id, 
 max_date) retrieved with a groupby on the emp_id and the second set to 
 match would be the (id, date) tuple to use to match the name.

 You can do it with two selects and merging sets with python, or figure 
 out a clean API that is supported on most of the backends :-P


 BTW: check the LATERAL joins that are available in postgresql 9.3 ... 
 will probably blow your head


-- 
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: crash - session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL) on 2.9.11

2014-12-02 Thread Remco Boerma
What solved my issue was registering with copy_reg. 
I store an instance  of my own class in the session, which now brakes 
without a registered reduction function. 
Though the class implements __getstate__ and __setstate__ apparently that 
isn't enough anymore. 
For docs 
checkout https://docs.python.org/2/library/pickle.html#module-pickle 
and https://docs.python.org/2/library/copy_reg.html

Hope this helps. 


Op woensdag 19 november 2014 15:54:13 UTC+1 schreef Edwin van de Ven:



 Op maandag 13 oktober 2014 19:22:57 UTC+2 schreef Dmitry Ermolaev:

 I del al files in /sessions and update to 2.9.11

 Traceback (most recent call last):
   File C:\web2py-m\gluon\main.py, line 435, in wsgibase
 session.connect(request, response)
   File C:\web2py-m\gluon\globals.py, line 931, in connect
 session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
 TypeError: 'NoneType' object is not callable


 I'm getting the exact same error after upgrading to 2.9.11. My sessions 
 directory is also empty. Does anyone else experience similar behavior? 


-- 
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: web2py 2.9.6 is out!

2014-09-02 Thread Remco Boerma
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: new web2py videos

2014-09-02 Thread Remco Boerma
Thanks Nico, Massimo

-- 
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: What am i doing wrong here? (virtualfields)

2014-08-26 Thread Remco Boerma
Exactly, i noticed the difference between the 4th and 6th too late, but now 
that i know... A workaround to this confusion would be highly appreciated. 

Remco

Op woensdag 20 augustus 2014 16:57:44 UTC+2 schreef Anthony:

 Depends on where you look in the book: 
 http://www.web2py.com/books/default/chapter/35/06/the-database-abstraction-layer
  
  - i just copied that line yesterday. Because of the differences between 
 your line and mine i googled 'virtual fields web2py' 
 https://www.google.nl/search?hl=nlq=db.item.total_price+%3D+Field.Virtual(meta=aq=foq=gws_rd=ssl#hl=nlq=Virtual+Fields+Web2py
  
 and found both old (4th edition) and new documentation (6th edition)in the 
 book. 


 Your first link is to the Chinese translation of the book, which is (a) 
 incomplete (therefore, most of it is still English) and (b) still at the 
 4th edition. We should probably do something to avoid this confusion when 
 coming from Google search results. In the meantime, please be sure to link 
 to the current English edition: http://web2py.com/book. 

 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.


[web2py] Re: What am i doing wrong here? (virtualfields)

2014-08-20 Thread Remco Boerma


 I forgot this was changed -- now AttributeError exceptions in the virtual 
 fields function fail silently, simply foregoing the creation of the virtual 
 field value for the record (which is why you got no error but didn't see 
 the value in the record).


Gotcha, thanks!
 

  

  Instead, it should be:
  

 db.myorder.c = Field.Virtual('c', lambda row: row.myorder.a * row.
 myorder.b)

 In the function, you must include the table name when accessing fields 
 in the row. Also, note that even when creating the virtual field via 
 assignment, you should still specify the name of the virtual field within 
 Field.Virtual() -- otherwise the name attribute of the virtual field will 
 be set to unknown, which may cause problems in some contexts.


 Thanks for the enlightenment. I've tried your change, and now it gives me 
 the proper result. But i don't get your remark about the name attribute. I 
 can't find that in the book for new style virtual classes, can you offer me 
 a pointer? When looking at  db.item.total_price = 
 Field.Virtual(lambda row: row.unit_price*row.quantity) from the book 
 (mind the table name not being used here either) i thought the name 
 assignment would be automatic by using db.myorder.c 


 Note, the book code is actually:

 db.item.total_price = Field.Virtual(
 'total_price',
 lambda row: row.item.unit_price*row.item.quantity)



Depends on where you look in the 
book: 
http://www.web2py.com/books/default/chapter/35/06/the-database-abstraction-layer
 
 - i just copied that line yesterday. Because of the different i googled 
'virtual fields web2py' and found both old and new documentation in the 
book. 
 

 Notice the first argument to Field.Virtual is 'total_price'. If you do 
 that, then db.item.total_price.name will be 'total_price'. If you don't 
 do that, then db.item.total_price.name will be 'unknown', which will 
 cause problems in some cases where the field's name attribute is used. 
 This is not explicitly mentioned in the book, though the book examples do 
 include the name explicitly.


All clear when looking at the right page, thanks. 
 

 Virtual fields are not stored in the database but are calculated after 
 records are pulled from the database, so they are not to be listed in the 
 call to .select().


 Can a notimplemented exception be justified in such a case?


 I think that particular exception is for methods within classes that have 
 not been implemented. In any case, I don't think this case justifies a new 
 custom exception. Should probably just be handled with documentation.


True, maybe a lookuperror might suite better, but then docs are a much 
better solution anyway. 

Remco 

-- 
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: Issue 1961; redirect, response.headers and CAS

2014-08-19 Thread Remco Boerma
http://www.html5rocks.com/en/tutorials/cors/ 
http://www.w3.org/TR/cors/
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

This is what you look for i think, it's what i've used and offers a lof of 
info. 

Op woensdag 13 augustus 2014 20:07:21 UTC+2 schreef Massimo Di Pierro:

 Can you point me to any documentation?

 On Wednesday, 13 August 2014 04:52:00 UTC-5, Remco Boerma wrote:

 Thanks Massimo, 

 Well, with CORS it depends. I used these to get CORS working with at IE11 
 and Chrome (latest)

 response.headers['Access-Control-Allow-Origin'] 
 response.headers['Access-Control-Allow-Methods'] 
 response.headers['Access-Control-Allow-Headers'] 

 Maybe something more dynamic like 
 auth.cas_allowed_headers_on_redirect = ['Acces-Co...',...]

 though it would require more tuning and more work and less out of the box 
 functionality. 

 For what i have seen it needs these headers on every contact with the 
 requesting browser, since the entire process is done using ajax that means 
 all redirects would probably apply. And if not, probably you'll want to 
 setup a structure to allow CORS on those redirects anyway. 
 If you really need to know which redirects are used in my situation (i 
 don't use the form based authentication obviously, so that might save me a 
 few redirects) i can debug the lot and see what i can come up with. 

 With kind regards. 

 Op woensdag 13 augustus 2014 07:29:43 UTC+2 schreef Massimo Di Pierro:

 Looking into this but I need your help. We cannot preserve all the 
 headers because some of them may contain sensitive information that should 
 not be sent cross domain (for example session cookies). So the question is, 
 which headers should be preserved by which redirects:

 There are two redirects in gluon/contrib/login_methods/cas_auth.py

 There are two redirects in gluon/tools.py in Auth allow_access.

 Do you know which ones need the headers? Which headers?

 On Tuesday, 12 August 2014 03:05:27 UTC-5, Remco Boerma wrote:

 Thanks Massimo, 

 Concerning https://code.google.com/p/web2py/issues/detail?id=1961can=1 

 The CAS structure uses redirect() internally. Can you update the call in 
 the CAS code to send the request.headers? That's why i proposed a change 
 on all redirect calls. This allows the CAS to be CORS compliant if the 
 user provides the proper headers on the controller level 

 With kind regards. 

 Remco



-- 
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: What am i doing wrong here? (virtualfields)

2014-08-19 Thread Remco Boerma


Op woensdag 13 augustus 2014 15:00:38 UTC+2 schreef Anthony:

 def new_style_virtual_field_test():

 db = DAL('sqlite:memory',pool_size=1)
 db.define_table('myorder',
 Field('a','integer'),
 Field('b','integer')
 )
 db.myorder.c = Field.Virtual(lambda row:row.a * row.b)
 db.myorder.insert(a=2,b=3)
 return db().select(db.myorder.ALL).first().as_json()
 # {a: 2, id: 1, b: 3}


 Are you sure that's the exact code you have run, because row.a * row.b is 
 not the correct syntax and should result in an exception as soon as you do 
 a select.


It is, just tested this. I'm using 2.9.5-stable+timestamp.2014.03.16.02.35.39 
using python 2.7.3
 

 Instead, it should be:
  

db.myorder.c = Field.Virtual('c', lambda row: row.myorder.a * row.myorder.b)

 In the function, you must include the table name when accessing fields in 
 the row. Also, note that even when creating the virtual field via 
 assignment, you should still specify the name of the virtual field within 
 Field.Virtual() -- otherwise the name attribute of the virtual field will 
 be set to unknown, which may cause problems in some contexts.


Thanks for the enlightenment. I've tried your change, and now it gives me 
the proper result. But i don't get your remark about the name attribute. I 
can't find that in the book for new style virtual classes, can you offer me 
a pointer? When looking at  db.item.total_price = Field.Virtual(lambda 
row: row.unit_price*row.quantity) from the book (mind the table name not 
being used here either) i thought the name assignment would be automatic by 
using db.myorder.c 

def new_style_virtual_field_test_anthony():
db = DAL('sqlite:memory',pool_size=1)
db.define_table('myorder',
Field('a','integer'),
Field('b','integer')
)
db.myorder.c = Field.Virtual(lambda row:row.myorder.a * row.myorder.b)
# added tablenames in the lambda 
db.myorder.insert(a=2,b=3)
return db().select(db.myorder.ALL).first().as_json()
# {a: 2, c: 6, b: 3, id: 1}
# hurray
 

return db().select(db.myorder.a, db.myorder.b, 
 db.myorder.c).first().as_json()
 # class 'sqlite3.OperationalError' no such column: None.unknown
 # (self=gluon.dal.SQLiteAdapter object, *a=('SELECT myorder.a, 
 myorder.b, None.unknown FROM myorder;',), **b={})
 
 # where has my C field gone to? 

  
 Virtual fields are not stored in the database but are calculated after 
 records are pulled from the database, so they are not to be listed in the 
 call to .select().


Can a notimplemented exception be justified in such a case?
 

 def old_style_virtual_field_test1():
 db = DAL('sqlite:memory',pool_size=1)
 db.define_table('myorder',
 Field('a','integer'),
 Field('b','integer')
 )
 class MyVirtualFields(object):
 def c(self):
 return self.myorder.a * self.myorder.b
 db.myorder.virtualfields.append(MyVirtualFields())
 db.myorder.insert(a=2,b=3)
 # return db().select(db.myorder.ALL).first().as_json()
 # {a: 2, id: 1, b: 3}
 # where is c? 


 Don't know. When I run the exact code above, I get:

 {a: 2, c: 6, b: 3, id: 1}


My bad, i get the same. 

return db().select(db.myorder.a, db.myorder.b, 
 db.myorder.c).first().as_json()
 # AttributeError: 'Table' object has no attribute 'c'

 # it doesn't ? I thought i declared to be virutally present


 Old style virtual fields work differently -- they don't result in 
 individual field attributes being added to the table object. Rather, they 
 are stored in the virtualfields attribute of the table.



def old_style_virtual_field_test1_anthony():
db = DAL('sqlite:memory',pool_size=1)
db.define_table('myorder',
Field('a','integer'),
Field('b','integer')
)
class MyVirtualFields(object):
def c(self):
return self.myorder.a * self.myorder.b
db.myorder.virtualfields.append(MyVirtualFields())
db.myorder.insert(a=2,b=3)
return db().select(db.myorder.a, db.myorder.b).first().as_json()
# Don't include the virtual fields on .select, they're implied 
# {a: 2, c: 6, b: 3}
# hurray!

I removed the db.myorder.c from the select and not it works. Above is the 
working sample left here for reference - this way it's basically the same 
as the above statement using old style virtual fields. 
 

 db.myorder.setvirtualfields(myorder=MyVirtualFields())
 # type 'exceptions.AttributeError' 'Table' object has no attribute 
 'setvirtualfields'
 # maybe a bit more clarity in the documentation would be nice. I 
 understand the purpose
 # but it's easily overlooked.


 The book seems fairly clear to me on this point. The only example it shows 
 using .setvirtualfields() is in the context of creating virtual fields on 
 the result of a join, with the following code:

 rows.setvirtualfields(order_item=MyVirtualFields())

 It then says (highlights added):

 Notice how in this 

[web2py] What am i doing wrong here? (virtualfields)

2014-08-13 Thread Remco Boerma
Hi all, 

I don't get the following errors and results. My goal is to have a virtual 
field and i can't get it to work the way i want it - and what i think is 
described in the book as it should work. What am i doing wrong here? 

Below are serveral independent samples of what i thought had to work, 
though old_style_virtual_field_test2 will never work and is obvious. 

Thanks for helping out. 
Remco Boerma

# web2py 2.9.5-stable+timestamp.2014.03.16.02.35.39

def new_style_virtual_field_test():
db = DAL('sqlite:memory',pool_size=1)
db.define_table('myorder',
Field('a','integer'),
Field('b','integer')
)
db.myorder.c = Field.Virtual(lambda row:row.a * row.b)
db.myorder.insert(a=2,b=3)
return db().select(db.myorder.ALL).first().as_json()
# {a: 2, id: 1, b: 3}
# where is c?

return db().select(db.myorder.a, db.myorder.b, 
db.myorder.c).first().as_json()
# class 'sqlite3.OperationalError' no such column: None.unknown
# (self=gluon.dal.SQLiteAdapter object, *a=('SELECT myorder.a, 
myorder.b, None.unknown FROM myorder;',), **b={})

# where has my C field gone to? 


def old_style_virtual_field_test1():
db = DAL('sqlite:memory',pool_size=1)
db.define_table('myorder',
Field('a','integer'),
Field('b','integer')
)
class MyVirtualFields(object):
def c(self):
return self.myorder.a * self.myorder.b
db.myorder.virtualfields.append(MyVirtualFields())
db.myorder.insert(a=2,b=3)
# return db().select(db.myorder.ALL).first().as_json()
# {a: 2, id: 1, b: 3}
# where is c? 

return db().select(db.myorder.a, db.myorder.b, 
db.myorder.c).first().as_json()
# AttributeError: 'Table' object has no attribute 'c'

# it doesn't ? I thought i declared to be virutally present

def old_style_virtual_field_test2():
db = DAL('sqlite:memory',pool_size=1)
db.define_table('myorder',
Field('a','integer'),
Field('b','integer')
)
class MyVirtualFields(object):
def c(self):
return self.myorder.a * self.myorder.b
db.myorder.setvirtualfields(myorder=MyVirtualFields())
# type 'exceptions.AttributeError' 'Table' object has no attribute 
'setvirtualfields'
# maybe a bit more clarity in the documentation would be nice. I 
understand the purpose
# but it's easily overlooked. 

def old_style_virtual_field_test3():
db = DAL('sqlite:memory',pool_size=1)
db.define_table('myorder',
Field('a','integer'),
Field('b','integer')
)
class MyVirtualFields(object):
def c(self):
return self.myorder.a * self.myorder.b
db.myorder.insert(a=2,b=3)

rows = db(db.myorder).select()
# now i have to apply them after selecting? That's counter intuitive
# i thought it would be in the model, not the controller 
rows.setvirtualfields(myorder=MyVirtualFields())
# also note the setvirtualfields has to be applied to the rows, not to 
a single row. 

return rows.first().as_json();
# {a: 2, c: 6, b: 3, id: 1} 
# yeey!!



-- 
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: Issue 1961; redirect, response.headers and CAS

2014-08-13 Thread Remco Boerma
Thanks Massimo, 

Well, with CORS it depends. I used these to get CORS working with at IE11 
and Chrome (latest)

response.headers['Access-Control-Allow-Origin'] 
response.headers['Access-Control-Allow-Methods'] 
response.headers['Access-Control-Allow-Headers'] 

Maybe something more dynamic like 
auth.cas_allowed_headers_on_redirect = ['Acces-Co...',...]

though it would require more tuning and more work and less out of the box 
functionality. 

For what i have seen it needs these headers on every contact with the 
requesting browser, since the entire process is done using ajax that means 
all redirects would probably apply. And if not, probably you'll want to 
setup a structure to allow CORS on those redirects anyway. 
If you really need to know which redirects are used in my situation (i 
don't use the form based authentication obviously, so that might save me a 
few redirects) i can debug the lot and see what i can come up with. 

With kind regards. 

Op woensdag 13 augustus 2014 07:29:43 UTC+2 schreef Massimo Di Pierro:

 Looking into this but I need your help. We cannot preserve all the headers 
 because some of them may contain sensitive information that should not be 
 sent cross domain (for example session cookies). So the question is, which 
 headers should be preserved by which redirects:

 There are two redirects in gluon/contrib/login_methods/cas_auth.py

 There are two redirects in gluon/tools.py in Auth allow_access.

 Do you know which ones need the headers? Which headers?

 On Tuesday, 12 August 2014 03:05:27 UTC-5, Remco Boerma wrote:

 Thanks Massimo, 

 Concerning https://code.google.com/p/web2py/issues/detail?id=1961can=1 

 The CAS structure uses redirect() internally. Can you update the call in the 
 CAS code to send the request.headers? That's why i proposed a change on all 
 redirect calls. This allows the CAS to be CORS compliant if the user 
 provides the proper headers on the controller level 

 With kind regards. 

 Remco



-- 
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] Issue 1961; redirect, response.headers and CAS

2014-08-12 Thread Remco Boerma


Thanks Massimo, 

Concerning https://code.google.com/p/web2py/issues/detail?id=1961can=1 

The CAS structure uses redirect() internally. Can you update the call in the 
CAS code to send the request.headers? That's why i proposed a change on all 
redirect calls. This allows the CAS to be CORS compliant if the user provides 
the proper headers on the controller level 

With kind regards. 

Remco

-- 
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] smartgrid linked tables Query Not Supported: no such column undocumented feature

2014-05-14 Thread Remco Boerma

Hi, 

Working with the SQLFORM.smartgrid i found undocumented behaviour. 

If i use linked tables, the fields selection is required for the linked 
tables grid as well. This might need a tune up in the docs. As it is a grid 
and thus valid - it caught me by surprise. Reading in the grid view to 
mean in the main grid view... It's a great and noteworthy feature worth 
documentation. 

In that same order of thought: orderby gave me some fuzz on my project with 
the linked tables. As soon as the orderby is present, the ordering works 
perfectly in the main grid but i get an error and no results in the grids 
of the linked tables. ( The error is Query Not Supported: no such column: 
tile.name when i view a linked table ) Since one might want to have 
different ordering on different tables/grids it surely makes sense. With a 
table named 'tile' i found myself with the following line of code to have 
the ordering in the tile grid and an error free experience in the linked 
tables. 

options.orderby = (db.tile.name|~db.tile.effdt) if request.args[-1] == 
'tile' else None

After which i've learnt there is an easier undocumented way: 

options.orderby = {'tile':(db.tile.name|~db.tile.effdt)}

My question would be to ask for an update of the documentation and have 
this article for future reference if someone encounters the same error.


This comes from the website: 


   - fields is a list of fields to be fetched from the database. It is also 
   used to determine which fields to be shown in the grid view. However, it 
   doesn't control what is displayed in the separate form used to edit rows. 
   For that, use the readable and writable attribute of the database fields. 
   For example, in a editable grid, suppress updating of a field like this: 
   before creating the SQLFORM.grid, set
   - orderby is used as default ordering for the rows.


regards, 
Remco 

-- 
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: Issue 1865 code sample as requested

2014-04-23 Thread Remco Boerma
Massimo, 

Thanks for responding in the comment. I've responded to yours but don't 
know if you'd prefer bringing that over to the mailing list or not. 
What's the rule of thumb for that - when to file a bug and keep on posting 
there and when to write to the mailinglist?

Regards, 
Remco 

Op dinsdag 15 april 2014 14:48:43 UTC+2 schreef Remco Boerma:

 Hi, 

 I've finally had the time to play a little with the code sample that was 
 requested on issue 1865. It's in the comment there. 

 https://code.google.com/p/web2py/issues/detail?id=1865

 -- 
 Cheers / Met vr. gr. 
 Remco Boerma 


-- 
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] Issue 1865 code sample as requested

2014-04-15 Thread Remco Boerma
Hi,

I've finally had the time to play a little with the code sample that was
requested on issue 1865. It's in the comment there.

https://code.google.com/p/web2py/issues/detail?id=1865

-- 
Cheers / Met vr. gr.
Remco Boerma

-- 
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] Book layout appears broken

2014-03-11 Thread Remco Boerma
http://web2py.com/books/default/chapter/29/09/access-control#Renaming-Auth-tables


There's a screwup of the layout starting somewhere in that section.


-- 
Cheers / Met vr. gr.
Remco Boerma

-- 
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 ADMIN !!

2014-01-10 Thread Remco Boerma
Github complains about the file being to big? Can i download it somewhere 
else? 

https://github.com/pyner/admin_plus/blob/master/web2py.plugin.admin_plus.w2p


-- 
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/groups/opt_out.


[web2py] Re: SQL error using APP Admin

2013-12-19 Thread Remco Boerma


 Created a ticket for 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/groups/opt_out.


[web2py] SQL error using APP Admin

2013-12-18 Thread Remco Boerma
Hi, 

When i use appadmin to view the tables and i click on a single entry to 
view that entry i get an error.  

I open 
https://lvwaso01.rocdc.local/dc_jobs/appadmin/update/db/JobPlatform/3

and get: 
class 'pyodbc.ProgrammingError' ('42000', [42000] [FreeTDS][SQL 
Server]Column 'Platform.ApplicationDomain' is invalid in the select list 
because it is not contained in either an aggregate function or the GROUP BY 
clause. (8120) (SQLExecDirectW))

Here's the full traceback:
Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 217, in restricted
exec ccode in environment
  File 
/home/www-data/web2py/applications/dc_jobs/controllers/appadmin.py, line 
654, in module
  File /home/www-data/web2py/gluon/globals.py, line 372, in lambda
self._caller = lambda f: f()
  File 
/home/www-data/web2py/applications/dc_jobs/controllers/appadmin.py, line 
342, in update
f='download', args=request.args[:1]))
  File /home/www-data/web2py/gluon/sqlhtml.py, line 1145, in __init__
inp = self.widgets.options.widget(field, default)
  File /home/www-data/web2py/gluon/sqlhtml.py, line 270, in widget
options = requires[0].options()
  File /home/www-data/web2py/gluon/validators.py, line 559, in options
self.build_set()
  File /home/www-data/web2py/gluon/validators.py, line 545, in build_set
records = self.dbset(table).select(*fields, **dd)
  File /home/www-data/web2py/gluon/dal.py, line 10335, in select
return adapter.select(self.query,fields,attributes)
  File /home/www-data/web2py/gluon/dal.py, line 1831, in select
return self._select_aux(sql,fields,attributes)
  File /home/www-data/web2py/gluon/dal.py, line 1796, in _select_aux
self.execute(sql)
  File /home/www-data/web2py/gluon/dal.py, line 1916, in execute
return self.log_execute(*a, **b)
  File /home/www-data/web2py/gluon/dal.py, line 1910, in log_execute
ret = self.cursor.execute(command, *a[1:], **b)
ProgrammingError: ('42000', [42000] [FreeTDS][SQL Server]Column 
'Platform.ApplicationDomain' is invalid in the select list because it is 
not contained in either an aggregate function or the GROUP BY clause. 
(8120) (SQLExecDirectW))

Troling uptward through the traceback i noticed that at File 
/home/www-data/web2py/gluon/validators.py in build_set at line 54 in the 
variables there is a group by defined:

   - dd: {'cache': None, 'cacheable': True, 'distinct': None, 'groupby': 
   'Platform.Straat', 'orderby': 'Platform.DocumentationLink'}
   - 
   
before that i didn't see it. 

Here's my model: 

VarcharMax = SQLCustomType(
 type ='text', # web2py type
 native='varchar(max)',
 )

db.define_table(Job,
  SQLField(Description, VarcharMax, notnull=True, default=''),
  SQLField(DocumentationLink, VarcharMax, default=''))

db.define_table(Platform,
  SQLField(ApplicationDomain, string, length=30, notnull=True, 
default=None),
  SQLField(ServerName, string, length=100, notnull=True, 
default=None),
  SQLField(DocumentationLink, VarcharMax, default=''),
  SQLField(Straat, string, length=3, notnull=True, default=None),
  format='%(ApplicationDomain)s:%(ServerName)s')

db.define_table(JobPlatform,
  SQLField(id_Job, db.Job),
  SQLField(id_Platform, db.Platform),
  SQLField(SecurityContext, string, length=100, notnull=True, 
default=None),
  SQLField(LocalIdentifier, string, length=300, notnull=True, 
default=None),
  SQLField(Description, VarcharMax, notnull=True, default=None),
  SQLField(DocumentationLink, VarcharMax, default=None),
  format='%(id_platform)s') 

I'm using revision f8df8f614cff (2.8.2)  (and not the latest from trunk 
because that breaks because of the sql server escaping)

Hope this is detailed enought for someone to easilty point out what's wrong 
here. 

With kind regards, 
Remco Boerma


-- 
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/groups/opt_out.


[web2py] sqlstatements in tracebacks are quite short

2013-12-17 Thread Remco Boerma
Hi, 

Sometimes some errors are a little hard to debug because of the crammed 
representation in the tracebacks. Especially when something with the 
database goes wrong and you can't see the entire sql statement being fired. 
Insert this in your model and see more of the statement in the traceback. 

import pydoctextrepr = pydoc.TextRepr()textrepr.maxstring = textrepr.maxother = 
1000pydoc.text.repr = textrepr.repr


With kind regards, 
Remco Boerma



-- 
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/groups/opt_out.


Re: [web2py] web2py 2.6.1 is OUT - IMPORTANT READ

2013-11-22 Thread Remco Boerma
Cheers,

And a big Thank you to all who have contributed!

With kind regards,
Remco Boerma


On Fri, Sep 13, 2013 at 12:27 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Web2py 2.6.1 is finally OUT. It needs some more testing.

 READ BELOW BEFORE UPGRADING

  Attention all users: For pre 2.6 applications to work with web2py
 =2.6, you must copy static/js/web2py.js, controllers/appadmin.py, and
 views/appadmin.html from the welcome app to your own apps (all of them).

  Attention production users: The updated handlers and examples are in
 handlers/ and examples/. The updated ones will not override the existing
 ones. To use the new ones it is not sufficient to upgrade web2py, you also
 need to copy the desired handler/example in the root web2py/ folder.

  Attention MySQL users: The length of string fields changed from 255
 to 512 bytes. If you have migrations enabled this will trigger a large
 migration. To prevent it, first set migrate_enabled=False, upgrade, check
 everything is ok, then add length=255 to your string Fields, then re-enable
 migrations with migrate_enabled=True if needed.

 - better directory structure: handlers/ extras/ examples/
 - better MongoDb support, thanks Alan
 - better Admin editor interface, thanks Paolo, Roberto (codemirror 3), and
 Lightdot
 - better layout.html and web2py_bootstrap.css, thanks Paolo
 - refactored web2py.js makes code more readable, thanks Niphlod
 - compute fields can depend on other compute(d) fields
 - more functions in appadmin (/manage/auth), thanks Anthony
 - support for CAST in SQL generation
 - new API jQuery('#component').reload()
 - new API rows.render()
 - new API table.field.referent, table._references
 - new API db(...).validate_and_update(...)
 - new API Wiki(..., force_render=True) renders the page source again
 instead of using cached
 - Wiki now automatically parses named component arguments
 @{f:a=1,b='twp',c=variable}
 - auth.get_or_create_user(login=False)
 - auth = Auth(crsf_protection = False) prevents creating sessions in
 login/register forms.
 - enable multiple renderers in wiki, thanks Alan
 - log messages from Auth are no longer translated (for speed and
 readability)
 - update jQuery mobile to 1.3.1
 - reduced memory footprint by conditionally loading Tk
 - faster pbkdf2 uses OpenSSL, thanks Michele
 - many speed improvements, thanks Michele
 - better session logic, prevents false positive when detecting session
 changes.
 - scripts/import_static.py converts a static site to a web2py app
 (experimental)
 - support for new http error code 451
 - profiler saves dump in dir, thanks Niphlod
 - upgraded pyfpdf, thanks Mariano
 - gluon/contrib/pdfinvoice.py for generating PDF invoices (assumes
 reportlab)
 - no more double submission of forms (even without crsf protection),
 thanks Niphlod
 - speedup for define_table, thanks Michele
 - settings.cfg to admin, thanks Paolo
 - many bugs fixed, thanks Niphlod, Michele, Roberto, Jonathan, and many
 others

 --
 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/groups/opt_out.




-- 
Cheers / Met vr. gr.
Remco Boerma

-- 
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/groups/opt_out.


[web2py] Re: Python 3 compatibility?

2013-08-09 Thread Remco Boerma
Hi,

Good thread all in all. I'm eager to start with python3 but if web2py isn't 
working with it, then why start with p3 in the first place? 

Since most of my currently important python applications are web2py based. 
Many other scripts rely on MoinMoin (same story) and for other scripts many 
are ported to powershell. 
Think i'll step up on Dante's python2 circle. 

Regards,

Op zaterdag 13 april 2013 02:51:23 UTC+2 schreef twan...@gmail.com:

 Hi,
 I'm interested (very interested) in a Python web framework that works with 
 Python 3.x (3.3+, in particular). What is the status of web2py's py3 
 support? I found a late-2011 thread in this group where Massimo was betting 
 that there would be a Python 2.8 and hence no pressing need to even care 
 about 3.x. Me, I have no interest in 2.y, and if web2py doesn't support the 
 current and in fact better version of Python then I will reluctantly have 
 to look elsewhere.
 Thanks in advance,
 -- B



-- 

--- 
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/groups/opt_out.




Re: [web2py] How to use DAL with effective dated queries

2012-09-04 Thread Remco Boerma
Thanks a lot! 
I hope you do find the time to write a pure DAL query, because i'm so eager 
to know how it can be done! 
But first i have a workaround that i'll be able to use... 

Op dinsdag 4 september 2012 10:06:08 UTC+2 schreef Niphlod het volgende:

 definitely. I don't have time to test at the moment a vanilla DAL 
 solution, but if you use 2.0.6 you can use 

 db.executesql(your query, fields=[db.person.EmployeeID, 
 db.person.name]) 
 and get back a normal rows object.

 Il giorno martedì 4 settembre 2012 09:23:43 UTC+2, Remco Boerma ha scritto:

 Indeed. The point is to get the list of employeenames based on the 
 effective date (so get the most up to date row not in the future). The 
 query i provided works, and there's no way that i know of to do it more 
 effectively. Your query would require a second roundtrip to the database 
  to get all the names for the found dates and that's what i want to avoid 
 because we use this technique also with sets of hundreds of thousands of 
 rows. 

 Anyone else who has a guess how to rewrite this using the DAL? Is there 
 any way to alias and subquery? Or can raw sql be added to the where clause? 

 Thanks

 Op donderdag 30 augustus 2012 11:02:02 UTC+2 schreef Niphlod het volgende:

 I think the point here is retrieve only the record with the same 
 employeeid that has the max date. if so, why can't we rewrite that ugly 
 query as (a much more performant)

 SELECT  
 EmployeeID, 
 MAX(effdt) 
 FROM person 
 WHERE (effdt  now) 
 GROUP BY EmployeeID

 ? it's because you need the name ?

 Il giorno giovedì 30 agosto 2012 08:32:21 UTC+2, Johann Spies ha scritto:

 Hallo Remco,


 Try this:
 import datetime
 now = datetime.datetime.now()
 query = db.person.effdt  now
 data = SQLFORM.grid(query)

 Regards
 Johann

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)



-- 





[web2py] How to use DAL with effective dated queries

2012-08-29 Thread Remco Boerma
Hi, 

Given a table like 
define_table(‘person’,Field(‘EmployeeID’),Field(‘name’),Field(‘effdt’,type=’date’))
And having a persons name changed on a specific date: 

|1| 1234 | G. Single | 2008-01-01 |
|2| 1234 | G. Single-Married | 2012-08-01 |
|3| 1234 | G. Single | 2015-05-01 | 
|4| 5678 | S. Else | 2006-01-01 | 


I want the current names. We use effective dated queries for this: 

Select p.EmployeeID, p.name from person p
Where p.effdt = (select max(p_ed.effdt) 
   from person p_ed  
 where p.employeeid = p_ed.employeeid
   and p_ed.effdt = sysdate)

Which will return me two rows (2 and 4 in this example - one row per person 
with their current name) with only one roundtrip to the database. 

I just can’t figure out how to rewrite this query to DAL and I would really 
like to. 
Any help is appreciated, thank you.  

With kind regards, 
Remco Boerma

-- 





[web2py] Re: book 4th edition in PDF

2012-01-17 Thread Remco Boerma
Thanks for writing the book. 

Concerning payment, i couldn´t find any information about stripe on your 
page, so i googled them and validated them at visa. I can imagine more 
people wouldn´t just trust their creditcard details to a form not knowing 
what system is handling the details and where it´s stored an so forth. 

Will buy the book now - trying.. 

Regards, 
Remco Boerma, the Netherlands




[web2py] Re: book 4th edition in PDF

2012-01-17 Thread Remco Boerma
Works, mastercard

[web2py] SSO on active directory

2011-07-27 Thread Remco Boerma
Hello all,

Here are my findings for enabling SSO via CAS using web2py, IIS and
isapi-wsgi. My main question is a feature request, hopefully someone will
come up with an even simpler or smarter solution.

What i've done is creating a simple CAS server application.
In a newly created application i've added to the model:

| auth.define_tables(username=True)
| ...
| auth.settings.cas_domains.append('domain')
| if request.env.get('remote_user','') != '':
|   auth.user =
auth.get_or_create_user(dict(username=request.env['remote_user']))

So now i have an application that automatically logs on anyone which is
validated via IIS with integrated security. This requires a setup using
ISAPI-WSGI (1) behind IIS. I've done it with a wsgi server at the root.
Directory security for this IIS website is set to Integratied Windows
Authentication (and no anonymous access is allowed). Now i've altered the
setup script to add a virtual directory 'cas' to host the same web2py
server, and therefore also the same application but allowed anonymous access
and set a domain user for anonymous access but no integrated windows
authentication. So now i have the web2py application hosted at the places:
  1. server/application - which forces integrated security
  2. server/cas/application - which allows only anonymous access


Next up is the cas client. So i've created another application that is a CAS
consumer which typically runs localhost, or anywhere for that matter. Which
was setup  using:

| my_cas_provider = 'http://server/application/default/user/cas'
| auth = Auth(db,cas_provider=my_cas_provider)

And this is where i missed a parameter as you will see in a later stage.

Now, when a user logs in on this application using chrome or ie he can
simply press the login button, and is redirected to the server where he is
automatically logged in using remote_user and is redirected back to the user
(without entering anything) only to see an errorticket on screen because the
validation of the cas ticket can't be completed. That's because the server
(like wget) doesn't support ntlm or anything that fancy, so can't reach the
 server/application. My guess would be to set my_cas_provider to '
http://server/cas/application/default/user/cas' but then the user has to
enter credentials again instead of having SSO.

So i finally came up with this:

In the client *after* auth.define_tables(username=True) is called, add the
following:

| cas_check_url = auth.settings.login_form.cas_check_url
| cas_check_url = cas_check_url.replace('application','cas/application')
| auth.settings.login_form.cas_check_url = cas_check_url

Now, we have set the validate routine to use the anonymous enabled IIS
website to validate the ticket whereas the user simply uses the SSO based on
the integrated security. Best of both!

Best of all, now you can have linux based web2py servers with windows SSO
using CAS.

Thanks Massimo and others for making this possible!

Now, my request is this: is there a smarter/easier way to do this - mostly
focussed on the order in which the settings in the model have to be made.
The login form is recreated using a CasAuth instance in de define_table
method. Not something i thought very intuitive.

I'm eager to see your opinions on this.


With kind regards,
Remco Boerma

(1) isapi-wsgi: http://code.google.com/p/isapi-wsgi/