Re: [web2py] Re: REF: DAL Catching errors

2014-01-10 Thread Teddy Nyambe
Tried the example you gave me:

Try:

Except IntegrityError:



I am getting unresolved reference 'IntegrityError'

Kind regards,


On Thu, Jan 9, 2014 at 6:01 PM, Teddy Nyambe software@gmail.com wrote:

 Thanx Anthony,

 I will use [try]
 On 9 Jan 2014 15:52, Anthony abasta...@gmail.com wrote:

 try:
 db.test.insert(...)
 except IntegrityError:
 [return friendly error message]

 Of course, if the inserts are done via form submission, you should
 instead add an IS_NOT_IN_DB validator, in which case, it will automatically
 check for duplicates and return the appropriate error message. Even if not
 using a form, you can make use of the validator by using the
 .validate_and_insert() method.

 Anthony

 On Thursday, January 9, 2014 2:31:00 AM UTC-5, software.ted wrote:

 Hi,

 I am trying to find out the best way to catch errors generated by
 web2py especially those genereted by say DAL. Say forinstance if I
 have a table:

 db.define_table('test', Field('xyz', 'integer', unique=True)

 If i insert a dublicate field will get the exception and ticket:

 IntegrityError: (1062, uDuplicate entry 'X' for key 'xyz')

 Now i want to catch such an error and send a better message to a user,
 not the ticket etc.

 Any ideas?

 --
 ...

 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

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




-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 
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] help with request

2014-01-10 Thread Tarun Kumar
Hi! people I am new to web2py and web development. I am a bit confused 
about the request object. In its variables which can be accessed by 
request.vars.variable_name are the values stored only for the most recent 
request or for all the past requests. 
Considering the example given in web2py book overview section in which we 
use action attribute of the form and in the second function retrieve the 
visitors name using request.vars.visitor_name. My question is now that 
after a redirect to some other page will request.vars.visitor_name still be 
accessible?

Thanks in advanced and sorry if I am acting too dumb 

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

2014-01-10 Thread Alan Etkin
El lunes, 6 de enero de 2014 18:19:54 UTC-3, samuel bonill escribió:

 Admin Plus(A-Plus) is a web2py plugin that provides an easy-to-use 
 interface for managing your data


Wait, isn't this a similar project than this another?

https://groups.google.com/d/msg/web2py/9ajKQChEmHQ/lNzHUqTKaa8J

-- 
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: Error with virtual field (was: Re: [web2py] [ANN] Started development on web2admin)

2014-01-10 Thread rif
I am checking it right now, be back soon.

-rif

vineri, 10 ianuarie 2014, 01:28:37 UTC+2, Manuele a scris:

 Il 10/09/12 15:49, rif ha scritto: 
  I started the development of a new django-like admin interface. 
  
  You can find it here: https://github.com/rif/web2admin 
  
  It is very basic but still usable because it uses SQLFORM.smartgrid. 
  
  I am announcing it early because I need your feedback and feature 
  requests so that I can find out if grid will be able to support all 
  the desired features. 
  
  For quick start you can create a w2a_root group and add your user to 
  that group. 
  
  -rif 
  -- 



 Dear rif, 
 many compliments for the project! 
 I found a problem with virtual fields... but I don't know if it's 
 related to your plugin or directly to web2py. 
 I added a very simple virtual field like this one: 

 db.testtable.testfield = Field.Virtual(lambda row: 'foo') 

 and I obtain this error: 

 Traceback (most recent call last): 
   File /home/manuele/portali/web2py.git/gluon/restricted.py, line 217, 
 in restricted 
 exec ccode in environment 
   File 
 /home/manuele/portali/web2py.git/applications/paytorviewer/controllers/plugin_web2admin.py,
  

 line 116, in module 
   File /home/manuele/portali/web2py.git/gluon/globals.py, line 372, in 
 lambda 
 self._caller = lambda f: f() 
   File /home/manuele/portali/web2py.git/gluon/tools.py, line 3239, in f 
 return action(*a, **b) 
   File 
 /home/manuele/portali/web2py.git/applications/paytorviewer/controllers/plugin_web2admin.py,
  

 line 34, in view_table 
 showbuttontext = plugins.web2admin.showbuttontext, 
   File /home/manuele/portali/web2py.git/gluon/sqlhtml.py, line 2770, 
 in smartgrid 
 user_signature=user_signature, **kwargs) 
   File /home/manuele/portali/web2py.git/gluon/sqlhtml.py, line 2452, 
 in grid 
 value = row[str(field)] 
   File /home/manuele/portali/web2py.git/gluon/dal.py, line 7362, in 
 __getitem__ 
 raise ae 
 AttributeError: 'Row' object has no attribute 'unknown' 

 any idea? 

 Thank you 

 Manuele 


-- 
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] Writing Web2Py specification and finding free lance Web2Py coders

2014-01-10 Thread Timothy Swieter
I've got a couple web ideas I'd like to put into motion.  Some work will be 
done by myself, other work I'd like an expert (or at least someone more 
knowledgable than me) to do.  I'm thinking about writing a specification of 
sorts.  Is there any advice or templates recommended for creating a short 
specification for an app to be coded in Web2Py?

Along the same lines, I've looked and Googled on various free lance type 
web sites.  I hadn't don't noticed any particular place that has a critical 
mass of those listing Web2Py skills.  Plenty of Python or Python web app. 
 I wonder if there is a hangout I am missing where I could find those that 
code and create in Web2Py for a living or free lance that I could ask for a 
quote from.

Thank you - Tim

-- 
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: DAL auth_user usage problem

2014-01-10 Thread Alan Etkin



 AttributeError: 'Table' object has no attribute '('username', '')'


There's an now closed issue that is possibly related to this

http://code.google.com/p/web2py/issues/detail?id=1849

On what version did you try it?

-- 
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: Writing Web2Py specification and finding free lance Web2Py coders

2014-01-10 Thread Ruud Schroen
http://experts4solutions.com/ 

Is this what you are looking for?

On Friday, January 10, 2014 10:59:10 AM UTC+1, Timothy Swieter wrote:

 I've got a couple web ideas I'd like to put into motion.  Some work will 
 be done by myself, other work I'd like an expert (or at least someone more 
 knowledgable than me) to do.  I'm thinking about writing a specification of 
 sorts.  Is there any advice or templates recommended for creating a short 
 specification for an app to be coded in Web2Py?

 Along the same lines, I've looked and Googled on various free lance type 
 web sites.  I hadn't don't noticed any particular place that has a critical 
 mass of those listing Web2Py skills.  Plenty of Python or Python web app. 
  I wonder if there is a hangout I am missing where I could find those that 
 code and create in Web2Py for a living or free lance that I could ask for a 
 quote from.

 Thank you - Tim


-- 
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] Set default login controller

2014-01-10 Thread Ruud Schroen
I have my login form in the index page.

Is there a way to set the default login page to index? For example when try 
to open a page where you need to be logged in.

-- 
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: Error with virtual field (was: Re: [web2py] [ANN] Started development on web2admin)

2014-01-10 Thread rif
Unfortunately it seems to be a web2py grid/smartgrid bug. I opened a ticket 
here: http://code.google.com/p/web2py/issues/detail?id=1851

Meanwhile please note that defining an old style virtual field does not 
break the smartgrid:
class MyVirtualFields(object):
def testfield(self):
return 'foo'
db.testtable.virtualfields.append(MyVirtualFields())

I'll make a few updates to web2py with this occasion :)

Thanks,
-rif

vineri, 10 ianuarie 2014, 01:28:37 UTC+2, Manuele a scris:

 Il 10/09/12 15:49, rif ha scritto: 
  I started the development of a new django-like admin interface. 
  
  You can find it here: https://github.com/rif/web2admin 
  
  It is very basic but still usable because it uses SQLFORM.smartgrid. 
  
  I am announcing it early because I need your feedback and feature 
  requests so that I can find out if grid will be able to support all 
  the desired features. 
  
  For quick start you can create a w2a_root group and add your user to 
  that group. 
  
  -rif 
  -- 



 Dear rif, 
 many compliments for the project! 
 I found a problem with virtual fields... but I don't know if it's 
 related to your plugin or directly to web2py. 
 I added a very simple virtual field like this one: 

 db.testtable.testfield = Field.Virtual(lambda row: 'foo') 

 and I obtain this error: 

 Traceback (most recent call last): 
   File /home/manuele/portali/web2py.git/gluon/restricted.py, line 217, 
 in restricted 
 exec ccode in environment 
   File 
 /home/manuele/portali/web2py.git/applications/paytorviewer/controllers/plugin_web2admin.py,
  

 line 116, in module 
   File /home/manuele/portali/web2py.git/gluon/globals.py, line 372, in 
 lambda 
 self._caller = lambda f: f() 
   File /home/manuele/portali/web2py.git/gluon/tools.py, line 3239, in f 
 return action(*a, **b) 
   File 
 /home/manuele/portali/web2py.git/applications/paytorviewer/controllers/plugin_web2admin.py,
  

 line 34, in view_table 
 showbuttontext = plugins.web2admin.showbuttontext, 
   File /home/manuele/portali/web2py.git/gluon/sqlhtml.py, line 2770, 
 in smartgrid 
 user_signature=user_signature, **kwargs) 
   File /home/manuele/portali/web2py.git/gluon/sqlhtml.py, line 2452, 
 in grid 
 value = row[str(field)] 
   File /home/manuele/portali/web2py.git/gluon/dal.py, line 7362, in 
 __getitem__ 
 raise ae 
 AttributeError: 'Row' object has no attribute 'unknown' 

 any idea? 

 Thank you 

 Manuele 


-- 
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: Error with virtual field (was: Re: [web2py] [ANN] Started development on web2admin)

2014-01-10 Thread rif
I meant a few updates to web2admin :)

vineri, 10 ianuarie 2014, 13:46:24 UTC+2, rif a scris:

 Unfortunately it seems to be a web2py grid/smartgrid bug. I opened a 
 ticket here: http://code.google.com/p/web2py/issues/detail?id=1851

 Meanwhile please note that defining an old style virtual field does not 
 break the smartgrid:
 class MyVirtualFields(object):
 def testfield(self):
 return 'foo'
 db.testtable.virtualfields.append(MyVirtualFields())

 I'll make a few updates to web2py with this occasion :)

 Thanks,
 -rif

 vineri, 10 ianuarie 2014, 01:28:37 UTC+2, Manuele a scris:

 Il 10/09/12 15:49, rif ha scritto: 
  I started the development of a new django-like admin interface. 
  
  You can find it here: https://github.com/rif/web2admin 
  
  It is very basic but still usable because it uses SQLFORM.smartgrid. 
  
  I am announcing it early because I need your feedback and feature 
  requests so that I can find out if grid will be able to support all 
  the desired features. 
  
  For quick start you can create a w2a_root group and add your user to 
  that group. 
  
  -rif 
  -- 



 Dear rif, 
 many compliments for the project! 
 I found a problem with virtual fields... but I don't know if it's 
 related to your plugin or directly to web2py. 
 I added a very simple virtual field like this one: 

 db.testtable.testfield = Field.Virtual(lambda row: 'foo') 

 and I obtain this error: 

 Traceback (most recent call last): 
   File /home/manuele/portali/web2py.git/gluon/restricted.py, line 217, 
 in restricted 
 exec ccode in environment 
   File 
 /home/manuele/portali/web2py.git/applications/paytorviewer/controllers/plugin_web2admin.py,
  

 line 116, in module 
   File /home/manuele/portali/web2py.git/gluon/globals.py, line 372, in 
 lambda 
 self._caller = lambda f: f() 
   File /home/manuele/portali/web2py.git/gluon/tools.py, line 3239, in f 
 return action(*a, **b) 
   File 
 /home/manuele/portali/web2py.git/applications/paytorviewer/controllers/plugin_web2admin.py,
  

 line 34, in view_table 
 showbuttontext = plugins.web2admin.showbuttontext, 
   File /home/manuele/portali/web2py.git/gluon/sqlhtml.py, line 2770, 
 in smartgrid 
 user_signature=user_signature, **kwargs) 
   File /home/manuele/portali/web2py.git/gluon/sqlhtml.py, line 2452, 
 in grid 
 value = row[str(field)] 
   File /home/manuele/portali/web2py.git/gluon/dal.py, line 7362, in 
 __getitem__ 
 raise ae 
 AttributeError: 'Row' object has no attribute 'unknown' 

 any idea? 

 Thank you 

 Manuele 



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

2014-01-10 Thread rif
It sure looks like it, the more options the better :)

Anyhow if there are any features in A-Plus missing in web2admin please let 
me know, I'll try to keep up.

-rif

vineri, 10 ianuarie 2014, 11:26:48 UTC+2, Alan Etkin a scris:

 El lunes, 6 de enero de 2014 18:19:54 UTC-3, samuel bonill escribió:

 Admin Plus(A-Plus) is a web2py plugin that provides an easy-to-use 
 interface for managing your data


 Wait, isn't this a similar project than this another?

 https://groups.google.com/d/msg/web2py/9ajKQChEmHQ/lNzHUqTKaa8J



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

2014-01-10 Thread rif
You can clone the repo

git clone https://github.com/pyner/admin_plus.git

And you will have the w2p file available in the cloned directory.

vineri, 10 ianuarie 2014, 14:13:06 UTC+2, Remco Boerma a scris:

 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] request.uri_language

2014-01-10 Thread Gael Princivalle
Hello all.

I'm in trouble with language management.
Here is my routes.py at web2py root (standard):
routers = dict(

# base router
BASE=dict(
default_application='welcome',
),
)

Here is my routes.py in the test application (standard).
from fileutils import abspath
from languages import read_possible_languages

possible_languages = read_possible_languages(abspath('applications', app))

routers = {
app: dict(
default_language = possible_languages['default'][0],
languages = [lang for lang in possible_languages
   if lang != 'default']
)
}

In the test application, I've add this code at the end of the model db.py 
file:
if request.uri_language: T.force(request.uri_language)

And in my test application I've create this mypage page:
In controller:
def mypage():
request_uri_language = request.uri_language
return locals()

In view:
{{extend 'layout.html'}}
h1Template default/mypage.html/h1
{{=BEAUTIFY(response._vars)}}

If I try with mydomain.com/test/mypage
request_uri_language = en

If I try with mydomain.com/test/it/mypage I've got this error:
invalid function (default/it)

Someone can help me ?

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


[web2py] Re: !! NEW ADMIN !!

2014-01-10 Thread Alan Etkin


 You can clone the repo

 git clone https://github.com/pyner/admin_plus.git


Or use this

https://github.com/pyner/admin_plus/blob/master/web2py.plugin.admin_plus.w2p?raw=true

-- 
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: db modul creating question types

2014-01-10 Thread Timo Bahner
I'm trying to do something like this:

TEXT = 'text'
RADIO = 'radio'
SELECT = 'select'

QUESTION_TYPES = (
(TEXT, 'text'),
(RADIO, 'radio'),
(SELECT, 'checkboxes'),)

def get_choice():
choices = choices.split(',')
choices_list = []
for c in choices:
c = c.strip()
choices_list.append((c,c))
choices_tuple = tuple(choices_list)
return choices_tuple

db.define_table('survey',
Field('name', unique=True),
Field('created', 'datetime', default=request.now, writable=False),
Field('is_active', 'boolean', default=False))

db.survey.name.requires = IS_NOT_IN_DB(db, db.survey.name)

db.define_table('question',
Field('survey', db.survey),
Field('title', length=200),
Field('created', 'datetime', default=request.now, writable=False),
Field('question_type', default='text', widget=SQLFORM.widgets.radio.
widget),
Field('choices', 'text', default=get_choice())
)

db.question.survey.requires = IS_IN_DB(db, db.survey.id)
db.question.question_type.requires = IS_IN_SET(QUESTION_TYPES)Enter code 
here...

Now I need somehow to call get_choice() from db.question.choice to split 
radio and checkbox answers.

Again: what I'm trying to accomplish is to set up a survey. I want to 
create a set of questions with appadmin which can include radio, checkboxes 
or text answers.

P.S. I'm fairly new to python :)

-- 
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: Set default login controller

2014-01-10 Thread Anthony
auth = Auth(db, function='index')

will move all the Auth actions to the index function.

auth.settings.login_url = URL('default', 'index')

will move just the login action (i.e., redirects for login will go there).

Consider that with this approach, you will be generating a login form on 
every home page load (there is some overhead involved with that).

Anthony

On Friday, January 10, 2014 6:24:21 AM UTC-5, Ruud Schroen wrote:

 I have my login form in the index page.

 Is there a way to set the default login page to index? For example when 
 try to open a page where you need to be logged in.


-- 
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] Re: REF: DAL Catching errors

2014-01-10 Thread Anthony
IntegrityError is defined by the database driver, so needs to be imported. 
Actually, I forgot, we made this easier, so it is not adapter-dependent -- 
you can do:

try:
...
except db._adapter.driver.IntegrityError:
...

Another option is:

def insert_error_handler(table, fields, error):
[handle the error]

db.mytable._on_insert_error = insert_error_handler

There is also an _on_update_error callback.

Anthony

On Friday, January 10, 2014 3:53:17 AM UTC-5, software.ted wrote:

 Tried the example you gave me:

 Try: 
 
 Except IntegrityError: 
 


 I am getting unresolved reference 'IntegrityError'

 Kind regards,


 On Thu, Jan 9, 2014 at 6:01 PM, Teddy Nyambe softwa...@gmail.comjavascript:
  wrote:

 Thanx Anthony,

 I will use [try]
 On 9 Jan 2014 15:52, Anthony abas...@gmail.com javascript: wrote:

 try:
 db.test.insert(...)
 except IntegrityError:
 [return friendly error message]

 Of course, if the inserts are done via form submission, you should 
 instead add an IS_NOT_IN_DB validator, in which case, it will automatically 
 check for duplicates and return the appropriate error message. Even if not 
 using a form, you can make use of the validator by using the 
 .validate_and_insert() method.

 Anthony

 On Thursday, January 9, 2014 2:31:00 AM UTC-5, software.ted wrote:

 Hi, 

 I am trying to find out the best way to catch errors generated by 
 web2py especially those genereted by say DAL. Say forinstance if I 
 have a table: 

 db.define_table('test', Field('xyz', 'integer', unique=True) 

 If i insert a dublicate field will get the exception and ticket: 

 IntegrityError: (1062, uDuplicate entry 'X' for key 'xyz') 

 Now i want to catch such an error and send a better message to a user, 
 not the ticket etc. 

 Any ideas? 

 -- 
 ...
  

 Teddy Lubasi Nyambe 
 Opensource Zambia 
 Lusaka, ZAMBIA 

 Cell: +260 97 7760473 
 website: http://www.opensource.org.zm 

 ~/ 
 Human Knowledge belongs to the world! - AntiTrust 

 Man is a tool-using animal. Without tools he is nothing, with tools he 
 is all - Thomas Carlyle 1795-1881 

 /~ 

  -- 
 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 javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




 -- 

 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is 
 all - Thomas Carlyle 1795-1881

 /~ 


-- 
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] Re: !! NEW ADMIN !!

2014-01-10 Thread samuel bonill

 Hi,
 I tried this in my 'test' app which has  just 2 tables (blog_post, emp).
 It worked great. Thanks.
 When I try in this my actual app with 50+ tables, the list of tables
 displayed in  
 127.0.0.1:8000/http://www.google.com/url?q=http%3A%2F%2F127.0.0.1%3A8000%2Fsa=Dsntz=1usg=AFQjCNFs1_JFhjr8Z-DCOM1R3AXQ16In5Qapp/plugin_admin_plus/index
 is just the 6 auth tables. What could be the reason? I gave
 plus_admin_plus_superuser permission to one user.


try  :  
127.0.0.1:8000/http://www.google.com/url?q=http%3A%2F%2F127.0.0.1%3A8000%2Fsa=Dsntz=1usg=AFQjCNFs1_JFhjr8Z-DCOM1R3AXQ16In5Q
app/plugin_admin_plus/install

-- 
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] help with request

2014-01-10 Thread Jonathan Lundell
On 10 Jan 2014, at 12:16 AM, Tarun Kumar reach.tarun.h...@gmail.com wrote:
 Hi! people I am new to web2py and web development. I am a bit confused about 
 the request object. In its variables which can be accessed by 
 request.vars.variable_name are the values stored only for the most recent 
 request or for all the past requests. 
 Considering the example given in web2py book overview section in which we use 
 action attribute of the form and in the second function retrieve the visitors 
 name using request.vars.visitor_name. My question is now that after a 
 redirect to some other page will request.vars.visitor_name still be 
 accessible?


Request is only the current request.

request.vars is a dictionary representing the URL's query string. If you want 
request.vars.visitor_name to be visible after a redirect, you must include it 
in the query string of the URL you're redirecting to.

Alternatively you could store the visitor_name in session, making it visible to 
subsequent requests.

-- 
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: Scheduler: Error retrieving status?

2014-01-10 Thread Niphlod
what db are you using ?
that error usually pops up when the scheduler can't access the scheduler_* 
tables.

On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:

 I'm just getting started with the scheduler and I'm getting an error when 
 I start it on windows 7:

 C:\www\web2pypython web2py.py -K my_app
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
 psycopg2
 ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
 Ingres(pyod
 bc), IMAP(imaplib)
 starting single-scheduler for my_app...
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status


 This error just continually repeats until I ctrl-c.
 Here is my scheduler.py:

 # coding: utf8
 def doit():
 print 'hello world'
 
 tasks = dict(
 doit=doit,
 )
 from gluon.scheduler import Scheduler
 scheduler = Scheduler(db, tasks)


 I created a single row in the scheduler_task table. What is causing this 
 error? How do I begin to debug this? (Note when browsing my site there are 
 no errors).



-- 
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: Error with virtual field

2014-01-10 Thread Manuele Pesenti
Il 10/01/14 12:47, rif ha scritto:
 I meant a few updates to web2admin :)
thank you very mutch rif for your interest!!
:) I'll use old style viertual fields for the moment

M.

-- 
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: auth.enable_record_versioning

2014-01-10 Thread Niphlod
auth.record_versioning is just callbacks on steroids :P

On Friday, January 10, 2014 5:12:58 AM UTC+1, Jayadevan M wrote:

 Great. You guys have thought about everything, huh? :)

 On Friday, January 10, 2014 1:50:36 AM UTC+5:30, Niphlod wrote:

 make your own versioning with database callbacks.

 http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#before-and-after-callbacks

 That way you can customize to whatever degree you like what happens when 
 a row gets deleted/updated/inserted at any step.

 On Thursday, January 9, 2014 3:46:27 AM UTC+1, Jayadevan M wrote:

 A question about record versioning.  Is it possible to have this ON and 
 still *not keep* deleted versions of the record in the original table? 
 2 reasons - 
 1) When there are tables with a number of deletes, the table will become 
 huge 
 2) If we are using hand-written SQLs in many places, we have to remember 
 to add the filter to fetch only the valid records ( I am assuming when we 
 write our SQLs, web2py will not automatically add a filter).



-- 
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: Scheduler: Error retrieving status?

2014-01-10 Thread User
postgresql.  Also my app which uses same database works and I can see the 
tables and the row in scheduler_task table from appadmin

On Friday, January 10, 2014 9:57:25 AM UTC-5, Niphlod wrote:

 what db are you using ?
 that error usually pops up when the scheduler can't access the scheduler_* 
 tables.

 On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:

 I'm just getting started with the scheduler and I'm getting an error when 
 I start it on windows 7:

 C:\www\web2pypython web2py.py -K my_app
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
 psycopg2
 ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
 Ingres(pyod
 bc), IMAP(imaplib)
 starting single-scheduler for my_app...
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status


 This error just continually repeats until I ctrl-c.
 Here is my scheduler.py:

 # coding: utf8
 def doit():
 print 'hello world'
 
 tasks = dict(
 doit=doit,
 )
 from gluon.scheduler import Scheduler
 scheduler = Scheduler(db, tasks)


 I created a single row in the scheduler_task table. What is causing this 
 error? How do I begin to debug this? (Note when browsing my site there are 
 no errors).



-- 
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: Multiple File Upload Form Works! - Need Help with validation for multiple files

2014-01-10 Thread Brando
From my research, it looks like maybe an onvalidation function is the way 
to do this.  Can someone confirm this?

Something like:

def validate_upload():
passed_validation = []
files = request.vars['upload_files']

for file in files:
extension_file = file.split('.')[-1]
if extension_file == [csv|txt]
passed_validation.append(file)

return passed_validation


Thoughts?








On Thursday, January 9, 2014 2:57:40 PM UTC-8, Brando wrote:

 Thanks to Calvin Morrison's excellent work here is a really simple 
 solution to uploading multiple items.  I need help validating multiple 
 files.  I can upload one .txt file without issue; however, if i choose more 
 than one it will not pass validation.  Can someone tell me what kind of 
 loop or function would help me validate files BEFORE they are uploaded? 
  Also, if there is a more elegant way to code the controller please let me 
 know.

 Model:
 db.define_table('uploads',
 Field('username', 'string'),
 Field('filename', represent = lambda x, row: None if x == None else 
 x[:45]),
 Field('up_file', 'upload', uploadseparate=True, 
 requires=IS_NOT_EMPTY()),
 Field('up_date', 'datetime'), 
 Field('up_size', 'integer', represent= lambda x, row: 
 quikr_utils.sizeof_fmt(x) ), 
 Field('notes', 'text'))

 Controller:
 def submit():
 import datetime
 form = FORM(LABEL(File(s):), INPUT(_name='up_files', _type='file', 
 _multiple=True, 
 requires=IS_UPLOAD_FILENAME(extension='txt|config|log')),INPUT(_type='submit'))
 if form.accepts(request.vars, formname=form):
 response.flash = 'form accepted'
 files = request.vars['up_files']
 if not isinstance(files, list):
 files = [files]
 for f in files:
 up_file = db.uploads.up_file.store(f, f.filename)
 i = db.uploads.insert(notes=request.vars.notes, 
 up_file=up_file, filename=f.filename, up_date= datetime.datetime.now())
 db.commit()
 elif form.errors:
 response.flash = 'form has errors'
 else:
 response.flash = 'please fill the form'
 return dict(form=form)




-- 
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: db modul creating question types

2014-01-10 Thread Paolo Caruccio
My suggestion:

First we change the 'question' table definition as follows

db.define_table('question',
Field('survey', db.survey),
Field('title', length=200),
Field('created', 'datetime', default=request.now, writable=False),
Field('question_type', 'string', default='text'),
Field('choices', 'text', default='')
)

After, in the view where is the form to build the question, we advice the 
user that the options (in the textarea) should be separated with commas if 
question type is in [radio, checkboxes, select].
So we will not parse the textarea content when the question is saved in 
database, but we will have to parse the question choices field in the 
controller that manages the survey.
For example (warning: code not optimized and tested, it is only a proof of 
concept):

def display_questions():
question_id = request.args(0)
question_selected = db(db.question.id==question_id).select().first()
question_type = question_selected.question_type
question_choices = question_selected.choices
question_title = question_selected.title
if question_type in ['radio', 'checkboxes', 'select']:
choices = [c.strip() for c in question_choices.split(',')]
if question_type == 'radio':
widget = SQLFORM.widgets.radio.widget
elif question_type == 'checkboxes':
widget = SQLFORM.widgets.checkboxes.widget
elif question_type == 'select':
widget = SQLFORM.widgets.options.widget
else:
widget = SQLFORM.widgets.string.widget
form = SQLFORM.factory(Field('question',
 label=question_title,
 widget=widget,
 requires=IS_IN_SET(choices)))
else:
form = SQLFORM.factory(Field('question',
 label=question_title,
 widget=SQLFORM.widgets.text.widget,
 requires=IS_NOT_EMPTY()))
if form.process().accepted:
... save the answer in database
else:
... display error message ...


return dict(form=form)

I hope that this help you to find the right solution.

Il giorno venerdì 10 gennaio 2014 14:42:55 UTC+1, Timo Bahner ha scritto:

 I'm trying to do something like this:

 TEXT = 'text'
 RADIO = 'radio'
 SELECT = 'select'

 QUESTION_TYPES = (
 (TEXT, 'text'),
 (RADIO, 'radio'),
 (SELECT, 'checkboxes'),)

 def get_choice():
 choices = choices.split(',')
 choices_list = []
 for c in choices:
 c = c.strip()
 choices_list.append((c,c))
 choices_tuple = tuple(choices_list)
 return choices_tuple

 db.define_table('survey',
 Field('name', unique=True),
 Field('created', 'datetime', default=request.now, writable=False),
 Field('is_active', 'boolean', default=False))

 db.survey.name.requires = IS_NOT_IN_DB(db, db.survey.name)

 db.define_table('question',
 Field('survey', db.survey),
 Field('title', length=200),
 Field('created', 'datetime', default=request.now, writable=False),
 Field('question_type', default='text', widget=SQLFORM.widgets.radio.
 widget),
 Field('choices', 'text', default=get_choice())
 )

 db.question.survey.requires = IS_IN_DB(db, db.survey.id)
 db.question.question_type.requires = IS_IN_SET(QUESTION_TYPES)Enter code 
 here...

 Now I need somehow to call get_choice() from db.question.choice to split 
 radio and checkbox answers.

 Again: what I'm trying to accomplish is to set up a survey. I want to 
 create a set of questions with appadmin which can include radio, checkboxes 
 or text answers.

 P.S. I'm fairly new to python :)

 P.P.S. Or maybe I can leave it like this (but remove get_choice() from 
 db.py), split radio and checkbox answers with a comma and creat a split 
 function in controller. How's that? Complicated?


-- 
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] keepvalues - need help with this

2014-01-10 Thread subbaraman . kiran
Hello All,
The *design *is: I have a custom form with the a controller that 
inserts/updates a table. Tthe form accepts data, and on successful 
submission of this form, it stays on the same page (there are no redirects 
to another page or form)
*Issue*: The problem am seeing is, when I update values in the form, and 
submit it, the entered values are lost when the form returns because of 
successful submit, or due to errors. I have tried to use keepvalues=True in 
the form.accepts() and form.process() methods. No luck.
Details below.

Since the page am building has specific design needs, I went with the 
option of a custom form, where I used the form.custom.* options quite a 
bit. Therefore input fields in the form look like this
 input type=text class=form-control 
   {{if form.errors.country:}}invalidinput{{pass}}
id=country name=country 
value={{=form.custom.inpval['country']}}
placeholder={{=form.custom.comment['country']}}

Also the controller is coded as below
x = db(db.x.x_id == auth.user.id).select().first()
if x:
form = SQLFORM(db.x, record=x)
else:
form = SQLFORM(db.x)
pass

 
# process the form
if form.accepts(request.vars, formname='basicinfo_form', keepvalues=True
):
response.flash = 'Basic Information updated successfully.'
elif form.errors:
response.flash = 'The submitted form contains errors. The fields in 
error are highlighted below.'
else:
response.flash = 'Please fill the form.'
pass

return dict(form=form)

I was thinking that maybe I should capture the request.vars and send it 
back to the view alongwith the form. 
If the request.vars.country value exists, then I use that, instead of the 
form.custom.inpval['country']. This only makes the view code a bit more 
verbose, but if it solves the problem, then nothing like it. 

Can anyone suggest what I could do to sort this out?
Thank you,
Kiran

P.S: I did take a look at all the conversations in the forum about 
keepvalues. None of them seemed to help me. Though I did find this one to 
be interesting and am curious if this is sorted out already: 
https://groups.google.com/forum/#!searchin/web2py/keepvalues$20on$20validate/web2py/MNEYo96Shzg/jjKZaMmfAgQJ

-- 
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: Need more than one value to unpack

2014-01-10 Thread Rufus
so, the string object,  val is not composed of two substrings separated by 
a space.  There are
no spaces in the val string, based on that error.

The way the statement looks, I would say it is expecting a time string of 
the format:

dd/mm/yy hh:mm

or similar

On Tuesday, January 7, 2014 1:10:45 PM UTC-5, Akash Agrawall wrote:

  Traceback (most recent call last):
   File 
 /home/hornet632/webapps/joyofreading/web2py/applications/AK_M14/controllers/appadmin.py,
  line 243, in select
 limitby=(start, stop))
   File /home/hornet632/webapps/joyofreading/web2py/gluon/dal.py, line 
 10335, in select
 return adapter.select(self.query,fields,attributes)
   File /home/hornet632/webapps/joyofreading/web2py/gluon/dal.py, line 2388, 
 in select
 return super(SQLiteAdapter, self).select(query, fields, attributes)
   File /home/hornet632/webapps/joyofreading/web2py/gluon/dal.py, line 1831, 
 in select
 return self._select_aux(sql,fields,attributes)
   File /home/hornet632/webapps/joyofreading/web2py/gluon/dal.py, line 1796, 
 in _select_aux
 self.execute(sql)
   File /home/hornet632/webapps/joyofreading/web2py/gluon/dal.py, line 1916, 
 in execute
 return self.log_execute(*a, **b)
   File /home/hornet632/webapps/joyofreading/web2py/gluon/dal.py, line 1910, 
 in log_execute
 ret = self.cursor.execute(command, *a[1:], **b)
   File /usr/local/lib/python2.7/sqlite3/dbapi2.py, line 66, in 
 convert_timestamp
 datepart, timepart = val.split( )
 ValueError: need more than 1 value to unpack




-- 
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: Scheduler: Error retrieving status?

2014-01-10 Thread User
I created a bare bones app and the scheduler seems to work without error.  
Not really sure what's happening with the problem app but if I had to guess 
I'm thinking it might be related to using

db._common_fields.append(standard_fields)

where standard_fields is a table with fields such as date_created, 
created_by, modified_by etc. which in turn has defaults like 
auth.user_id.  Unexpected by me, these got appended to the scheduler 
tables. Maybe there is some problematic interaction with this.

I'm going to try explicitly adding standard_fields to my app tables rather 
than using db._common_fields.append to see if that fixes it.


On Friday, January 10, 2014 10:53:22 AM UTC-5, User wrote:

 postgresql.  Also my app which uses same database works and I can see the 
 tables and the row in scheduler_task table from appadmin

 On Friday, January 10, 2014 9:57:25 AM UTC-5, Niphlod wrote:

 what db are you using ?
 that error usually pops up when the scheduler can't access the 
 scheduler_* tables.

 On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:

 I'm just getting started with the scheduler and I'm getting an error 
 when I start it on windows 7:

 C:\www\web2pypython web2py.py -K my_app
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL(
 psycopg2
 ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
 Ingres(pyod
 bc), IMAP(imaplib)
 starting single-scheduler for my_app...
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status


 This error just continually repeats until I ctrl-c.
 Here is my scheduler.py:

 # coding: utf8
 def doit():
 print 'hello world'
 
 tasks = dict(
 doit=doit,
 )
 from gluon.scheduler import Scheduler
 scheduler = Scheduler(db, tasks)


 I created a single row in the scheduler_task table. What is causing this 
 error? How do I begin to debug this? (Note when browsing my site there are 
 no errors).



-- 
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: Scheduler: Error retrieving status?

2014-01-10 Thread User
Ok that appears to have been the problem.  Getting rid of 
db._common_fields.append(standard_fields) fixed it.  Didn't hone in on the 
exact problem but maybe it's because I had not null on created_by, 
modified_by fields which defaulted to auth.user_id.  Does a scheduled task 
even have a concept of a logged in user?

On Friday, January 10, 2014 7:07:32 PM UTC-5, User wrote:

 I created a bare bones app and the scheduler seems to work without error.  
 Not really sure what's happening with the problem app but if I had to guess 
 I'm thinking it might be related to using

 db._common_fields.append(standard_fields)

 where standard_fields is a table with fields such as date_created, 
 created_by, modified_by etc. which in turn has defaults like 
 auth.user_id.  Unexpected by me, these got appended to the scheduler 
 tables. Maybe there is some problematic interaction with this.

 I'm going to try explicitly adding standard_fields to my app tables rather 
 than using db._common_fields.append to see if that fixes it.


 On Friday, January 10, 2014 10:53:22 AM UTC-5, User wrote:

 postgresql.  Also my app which uses same database works and I can see the 
 tables and the row in scheduler_task table from appadmin

 On Friday, January 10, 2014 9:57:25 AM UTC-5, Niphlod wrote:

 what db are you using ?
 that error usually pops up when the scheduler can't access the 
 scheduler_* tables.

 On Friday, January 10, 2014 2:09:26 AM UTC+1, User wrote:

 I'm just getting started with the scheduler and I'm getting an error 
 when I start it on windows 7:

 C:\www\web2pypython web2py.py -K my_app
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2014
 Version 2.8.2-stable+timestamp.2013.12.09.17.54.55
 Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL
 (psycopg2
 ), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), 
 Ingres(pyod
 bc), IMAP(imaplib)
 starting single-scheduler for my_app...
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status
 ERROR:web2py.scheduler.mycomputer#10144:Error retrieving status


 This error just continually repeats until I ctrl-c.
 Here is my scheduler.py:

 # coding: utf8
 def doit():
 print 'hello world'
 
 tasks = dict(
 doit=doit,
 )
 from gluon.scheduler import Scheduler
 scheduler = Scheduler(db, tasks)


 I created a single row in the scheduler_task table. What is causing 
 this error? How do I begin to debug this? (Note when browsing my site 
 there 
 are no errors).



-- 
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: Wiki.auth 401 error

2014-01-10 Thread jimbo
Pretty much give up on this, the wiki looked very promising when i first 
tried it, seems to be dead now,


Which is a pity as it looked a very good option when it was working.

On Sunday, 22 December 2013 19:54:25 UTC, jimbo wrote:

 This used to work, activate the built in wiki, then register, log in and I 
 got the wiki available. Now when I try to make a new wiki I get 401 even 
 though it lets me log on.

 Tried today and I get a 401 error when app accesses 
 /default/index/_create/index


 Thanks, Jimmy



-- 
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: Multiple File Upload Form Works! - Need Help with validation for multiple files

2014-01-10 Thread Brando
Success!  Here is how you can validate all files in a multiple file upload. 
 In this example if one document does not validate then the entire 
validation fails.  You could easily just drop the files that don't validate 
and only let the accepted files through for processing.  

*If anyone has a more elegant solution please let me know.*

def submit():
form = FORM(LABEL(), INPUT(_name='up_files', _type='file', 
_multiple=True, requires=IS_NOT_EMPTY()),INPUT(_type='submit')) # The 
multiple param lets us choose multiple files.
if form.accepts(request.vars, formname=file_upload, 
onvalidation=upload_validation): #onvalidation checks the uploaded files to 
make sure they are only txt, config, or log.
response.flash = 'Bro...uploading files' 
files = request.vars['up_files'] 
if not isinstance(files, list): #convert files to a list if they 
are not one already.
files = [files]
for file in files:
up_file = db.uploads.up_file.store(file, file.filename) #store 
is a FIELD method that let's you save a file to disk.  you can choose the 
directory if you want using the 'path' param.
else:
response.flash = 'Choose the Files you would like to upload'
return dict(form=form)


def upload_validation(form):
files = request.vars['up_files']
if not isinstance(files, list):
files = [files]
for file in files:
file_extension = file.filename.split('.')[-1] #find the file 
extension
acceptable_file = file_extension in ('txt', 'config', 'log') 
#choose the allowed file extensions
if not acceptable_file:
form.errors.up_files = Only .txt, .config, or .log files are 
allowed. #if they files are not acceptable return False. Validation 
failselse process the files.
return False



-- 
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] Re: REF: DAL Catching errors

2014-01-10 Thread Teddy Nyambe
thanks. it worked. but where is this documented?


On Fri, Jan 10, 2014 at 4:09 PM, Anthony abasta...@gmail.com wrote:

 IntegrityError is defined by the database driver, so needs to be imported.
 Actually, I forgot, we made this easier, so it is not adapter-dependent --
 you can do:

 try:
 ...
 except db._adapter.driver.IntegrityError:
 ...

 Another option is:

 def insert_error_handler(table, fields, error):
 [handle the error]

 db.mytable._on_insert_error = insert_error_handler

 There is also an _on_update_error callback.

 Anthony

 On Friday, January 10, 2014 3:53:17 AM UTC-5, software.ted wrote:

 Tried the example you gave me:

 Try:
 
 Except IntegrityError:
 


 I am getting unresolved reference 'IntegrityError'

 Kind regards,


 On Thu, Jan 9, 2014 at 6:01 PM, Teddy Nyambe softwa...@gmail.com wrote:

 Thanx Anthony,

 I will use [try]
 On 9 Jan 2014 15:52, Anthony abas...@gmail.com wrote:

 try:
 db.test.insert(...)
 except IntegrityError:
 [return friendly error message]

 Of course, if the inserts are done via form submission, you should
 instead add an IS_NOT_IN_DB validator, in which case, it will automatically
 check for duplicates and return the appropriate error message. Even if not
 using a form, you can make use of the validator by using the
 .validate_and_insert() method.

 Anthony

 On Thursday, January 9, 2014 2:31:00 AM UTC-5, software.ted wrote:

 Hi,

 I am trying to find out the best way to catch errors generated by
 web2py especially those genereted by say DAL. Say forinstance if I
 have a table:

 db.define_table('test', Field('xyz', 'integer', unique=True)

 If i insert a dublicate field will get the exception and ticket:

 IntegrityError: (1062, uDuplicate entry 'X' for key 'xyz')

 Now i want to catch such an error and send a better message to a user,
 not the ticket etc.

 Any ideas?

 --
 ...

 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he
 is all - Thomas Carlyle 1795-1881

 /~

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




 --
 
 ...
 Teddy Lubasi Nyambe
 Opensource Zambia
 Lusaka, ZAMBIA

 Cell: +260 97 7760473
 website: http://www.opensource.org.zm

 ~/
 Human Knowledge belongs to the world! - AntiTrust

 Man is a tool-using animal. Without tools he is nothing, with tools he is
 all - Thomas Carlyle 1795-1881

 /~

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




-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 
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] Re: REF: DAL Catching errors

2014-01-10 Thread Anthony
Another one of our great undocumented gems. :-)

-- 
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] Re: REF: DAL Catching errors

2014-01-10 Thread Teddy Nyambe
Hi Anthony!

Those gems we need to know!!!, since i have to extract undocumented details
on this list, I would like to find out how i can then get system generated
messages cause there are many integrity error descriptions...instead of me
having one message like this:

try:
...
except db._adapter.driver.IntegrityError:
err_msg = Duplicate record in database

I would like to have a situation were i can get system messages of the
specific integrity error enountered:

try:
...
except db._adapter.driver.IntegrityError:
err_msg = db.[some object].errorMessage


Any pointers?


On Sat, Jan 11, 2014 at 8:11 AM, Anthony abasta...@gmail.com wrote:

 Another one of our great undocumented gems. :-)

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




-- 
...
Teddy Lubasi Nyambe
Opensource Zambia
Lusaka, ZAMBIA

Cell: +260 97 7760473
website: http://www.opensource.org.zm

~/
Human Knowledge belongs to the world! - AntiTrust

Man is a tool-using animal. Without tools he is nothing, with tools he is
all - Thomas Carlyle 1795-1881

/~

-- 
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: Writing Web2Py specification and finding free lance Web2Py coders

2014-01-10 Thread Timothy Swieter
Ruud - 

I'll take a look at the organization you linked too.  On the face of it, 
this may be who I am looking for.  Have you any experience with them?  How 
are they?  What is their process of definition and development?  

Any other freelancers or commercial business that develop on Web2Py 
full-time?  

Thank you again.  

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