[web2py] Digitally signed URLs in py4web?

2020-02-13 Thread Luca
In web2py, I used to sign all the AJAX callback URLs, using the URL(..., 
user_signature=True) method. 

In py4web, I don't see any emphasis or use on signed URLs.  Why are signed 
URLs not commonly used in py4web? 

A digital signature is useful to prevent javascript running from other 
sites (e.g., www.attack.com) from performing AJAX calls to our site (e.g., 
www.example.com). 

Does the same-origin policy prevent these attacks?  I think not.  The 
problem is that the same-origin policy is implemented in the browser, with 
the help of headers returned from the server.  Thus, at the point when the 
policy is enforced, any side effects of the AJAX call (e.g., modifications 
to stored content) might have already happened.  Is my understanding 
correct?  If this is correct, then a way to digitally sign URLs in py4web 
is needed. 

Of course, even if we digitally sign the URLs, an attacker script could 
load the .html page first where the digitally signed URLs are -- but THIS 
is correctly prevented by the same-origin policy, hopefully. 

Is my analysis wrong? 

If we were to implement digitally signed URLs, is there already a random 
token in the user' session that can be used to sign the URLs? If not it 
would be easy to add. 

Sorry if this is kind of trivial to you all; I am just trying to figure out 
how to do things in py4web that I used to do in web2py... 
I think as useful practice, I am now going to implement a fixture or 
something like that to check for signatures... 

Luca

-- 
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/fbe04016-a07f-4612-9ede-1fb701684fb7%40googlegroups.com.


[web2py] Error in factories.py in py4web?

2020-02-13 Thread Luca
In the class ActionFactory, there's the code below.  Is that an error?  I 
don't think requires_login is in the proper place?  Maybe I don't 
understand. 

def put(self, path=None, template=None):
return self._action_maker('PUT', template, requires_login)

-- 
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/6ff44ddc-7f5e-47c0-a5e7-4fd8d6856e29%40googlegroups.com.


[web2py] Re: py4wb simplification

2020-02-13 Thread Luca
What do @authenticated and @unauthenticated do? 
Can they be added to the documentation? 

In particular I don't understand 

# define a button that make the following serverside POST callback
@unauthenticated.button("click me")
def a_button(msg):
print("you clicked the button and server received:", msg)

Thanks! 

Luca



Luca

On Friday, January 31, 2020 at 8:55:11 PM UTC-8, Massimo Di Pierro wrote:
>
> I committed some new code to py4web
>
> Now you can do:
>
> from . common import authenticated, unauthenticated # from latest _scaffold
>
> # exposes index as /{app_name}/index and uses index.html or generic.html 
> template, auth.user, db, T, session
> @authenticated()
> def index():
>   return dict()
>
> # GET only
> @authenticated.get()
> def index():
>   return dict()
>
> # exposes /{app_name}/index///
> @authenticated.get()
> def index(a,b,c):
>   return dict()
>
> # more explicit
> @authenticated.get("index///)
> def index(a,b,c):
>   return dict()
>
> Some magic
>
> # define a button that make the following serverside POST callback
> @unauthenticated.button("click me")
> def a_button(msg):
> print("you clicked the button and server received:", msg)
>
> # expose a page that displays the button which - onclick - makes the 
> ballback
> @unauthenticated.get()
> def show_a_button():
> return dict(mybutton = a_button(msg="hello world"))
>
> Thoughts? Should we keep this API? Can we improve 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/7b38abbe-3a07-41c1-9402-0204edf1e12d%40googlegroups.com.


[web2py] How to import pydal

2019-10-14 Thread Luca
I cloned pydal from github.  Then, from the directory where I cloned pydal, 
which is ~/work/WikiTrust2/data_interface, I tried to import it. 
However, I get an error: I can import DAL, but an import within pydal 
itself fails, probably because pydal does not know how to import its own 
modules due to Python 3 new import model. 

So my question is:  if I want to clone pydal from github as a submodule as 
part of a larger project, how do I then import pydal into the project? 

I am probably confused by the Python 3 import model (I was used to Python 
2); can someone help me out? 

Many thanks, 

Luca

from pydal.pydal import DAL
---
ModuleNotFoundError   Traceback (most recent call last)
 in 
> 1 from pydal.pydal import DAL

~/work/WikiTrust2/data_interface/pydal/pydal/__init__.py in 
  1 __version__ = '20190915.2'
  2
> 3 from .base import DAL
  4 from .objects import Field
  5 from .helpers.classes import SQLCustomType

~/work/WikiTrust2/data_interface/pydal/pydal/base.py in 
146 from .objects import Table, Field, Rows, Row, Set
147 from .adapters.base import BaseAdapter, NullAdapter
--> 148 from .default_validators import default_validators
149
150 TABLE_ARGS = set(

~/work/WikiTrust2/data_interface/pydal/pydal/default_validators.py in 

 10 """
 11
---> 12 from . import validators
 13
 14 def default_validators(db, field):

~/work/WikiTrust2/data_interface/pydal/pydal/validators.py in 
 29 from functools import reduce
 30
---> 31 from pydal._compat import StringIO, integer_types, basestring, 
unicodeT, urllib_unquote, \
 32 unichr, to_bytes, PY2, to_unicode, to_native, string_types, 
urlparse, ipaddress
 33 from pydal.objects import Field, FieldVirtual, FieldMethod, Table

ModuleNotFoundError: No module named 'pydal._compat'

-- 
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/1d88344a-974b-4551-be43-f06fa83f227c%40googlegroups.com.


[web2py] Re: storing IS_IN_SET items in appconfig.ini

2016-04-09 Thread Luca
Leonel, Anthony,

Thank you very much, both methods you mention work beautifully!

cheers,
Luca

On Sunday, April 10, 2016 at 1:24:44 AM UTC+10, Anthony wrote:
>
> On Saturday, April 9, 2016 at 10:34:00 AM UTC-4, Leonel Câmara wrote:
>>
>> You're doing nothing wrong, it's just the way the ConfigParser module 
>> works in python, remember that the only thing you have in a config file are 
>> strings, config files are not Python. Luckily AppConfig take has a cast 
>> argument which you can use for this. So instead of
>>  
>> tasks = ('Call', 'Meet', 'Email')
>> myconf.take('dropdown_choices.tasks')
>>
>> Do this in your appconfig.ini
>> [dropdown_choices]
>> tasks = Call,Meet,Email
>>
>> And in your model do this
>> myconf.take('dropdown_choices.tasks', cast=lambda foo: foo.split(','))
>>
>
> And with the latest version of web2py, you can now do:
>
> myconf.get('dropdown_choices.tasks')
>
> Note the use of .get instead of .take (.get is a smart version of .take 
> that does some automatic conversions, including converting comma separated 
> lists into Python lists -- you can even put spaces after the commas and it 
> will automatically strip them).
>
> 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] storing IS_IN_SET items in appconfig.ini

2016-04-08 Thread Luca
Hi everyone,

I'm new to web2py but learning fast, and building an online clients and 
tasks database for work, with some extra functionality. (similar to a CRM 
app...)

When I restrict the values in a table field by assigning IS_IN_SET 
directly, it works (a proper itemized dropdown list appears in the new 
records form):

in db.py: TASK_TYPES = ('Call', 'Meet', 'Email')
   db.tasks.task_type.requires=IS_IN_SET(TASK_TYPES)

BUT  when I place the same list in appconfig.ini and call it in db.py, 
the list is no longer 3 ordered choices, but a vertical list made of all 
the characters plus brackets and quote marks...

in appconfig.ini: 
[dropdown_choices]
tasks = ('Call', 'Meet', 'Email')

in 
db.py: 
db.tasks.task_type.requires=IS_IN_SET(myconf.take('dropdown_choices.tasks'))

tried converting it to a list with ...=list(..) but the result is the 
same.

what am I doing wrong? 

thanks in advance!

Luca

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

2016-02-20 Thread Luca Malatesta
Hi Antony and all,
I am getting the same errors. I tried to modify the code to fix it but no 
success until now.
Maybe Massimo (thanks for the help) will be able to figure it out.

I will keep you updated on this.

Il giorno venerdì 12 febbraio 2016 14:26:06 UTC+1, LightDot ha scritto:
>
> I've been using it in production for years, generating quite a few pdfs 
> daily. If I remember correctly, I made only minor modifications for my 
> needs.
>
> Can't help with your issue though.
>
> Regards
>
> On Friday, February 12, 2016 at 1:05:22 PM UTC+1, Anthony Smith wrote:
>>
>> Hi,
>> I gather this plugin is not correct and doesn't work without lots of work.
>>
>> cheers 
>> Anthony 
>>
>> On Tuesday, 9 February 2016 21:08:46 UTC+11, Anthony Smith wrote:
>>>
>>> Hi Massimo,
>>>
>>> Thanks for you help you can download form here 
>>> https://github.com/lucasdavila/web2py-appreport/wiki
>>>
>>> Thanks for looking into this 
>>>
>>> On Tuesday, 9 February 2016 13:37:01 UTC+11, Massimo Di Pierro wrote:

  do not know. Can you post this plugin? I have never seen it. Perhaps 
 assumes a library that is not installed.

 On Monday, 8 February 2016 02:24:38 UTC-6, Anthony Smith wrote:
>
> Hi Massimo, 
>
> Tried that and now getting this error 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
>
> Traceback (most recent call last):
>   File "/home/tony/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File 
> "/home/tony/web2py/applications/reports/models/plugin_appreport.py" 
> ,
>  line 25, in 
> import plugin_appreport as plugin_appreport_module
>   File "/home/tony/web2py/gluon/custom_import.py", line 85, in 
> custom_importer
> modules_prefix, globals, locals, [itemname], level)
>   File "applications/reports/modules/plugin_appreport/__init__.py", line 
> 2, in 
> import report_web2py
>   File "/home/tony/web2py/gluon/custom_import.py", line 89, in 
> custom_importer
> raise ImportError, 'Cannot import module %s' % str(e)
> ImportError: Cannot import module 
> 'applications.reports.modules.report_web2py'
>
>
> On Sunday, 7 February 2016 16:43:47 UTC+11, Massimo Di Pierro wrote:
>>
>> import modules.plugin_appreport as plugin_appreport_module
>>
>> should be
>>
>>
>> import plugin_appreport as plugin_appreport_module
>>
>>
>> On Saturday, 6 February 2016 00:38:24 UTC-6, Anthony Smith wrote:
>>>
>>> Hi All, 
>>>
>>> I was following the tutorial from 
>>> https://github.com/lucasdavila/web2py-appreport/wiki/Docs-and-examples, 
>>> Helper for simple reports and get the follow error when I try to open 
>>> the 
>>> app 
>>>
>>> Any ideas would be great 
>>>
>>>  Cannot import module 
>>> 'applications.reports.modules.modules'Version 
>>> web2py™ Version 2.13.4-stable+timestamp.2015.12.26.04.59.39 
>>> Python Python 2.7.6: /usr/bin/python (prefix: /usr) Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/tony/web2py/gluon/restricted.py", line 227, in restricted
>>> exec ccode in environment
>>>   File 
>>> "/home/tony/web2py/applications/reports/models/plugin_appreport.py" 
>>> ,
>>>  line 25, in 
>>> import modules.plugin_appreport as plugin_appreport_module
>>>   File "/home/tony/web2py/gluon/custom_import.py", line 89, in 
>>> custom_importer
>>> raise ImportError, 'Cannot import module %s' % str(e)
>>> ImportError: Cannot import module 'applications.reports.modules.modules'
>>>
>>>

-- 
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: Default time for datetime picker widget

2014-09-30 Thread Luca Liberti
What I was looking for was exactly some hint on how to do some "javascript"
tuning from within web2py. I am aware this might be a "borderline" question
not
completely belonging to the forum.

Thank you

On Wed, Sep 24, 2014 at 9:22 PM, Niphlod  wrote:

> let's break it down a bit.
> It's one thing to have a field "prefilled" with a default value and it's a
> totally different one to have a field empty by default but when you click
> on it it "presets" the time to 00:00.
>
> The former needs a Field(, default=something), the latter, given that
> the date(time) input is "managed" by a javascript component, needs a
> "javascript" tuning.
>
> Unfortunately, it seems that the version we're using can't accomodate for
> a "default time" for a datetime.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/AHiFwg2tZ4I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [web2py] Re: Default time for datetime picker widget

2014-09-24 Thread Luca Liberti
Thank you

I tried modifying the model as
Field('model_end_time', type='datetime',represent=lambda x, row: 'Active'
if x is None else
x.strftime("%Y-%m-%d"),default=datetime.datetime.now().replace(hour=0,minute=0,second=0,
microsecond=0))

I find that the datetime picker control still defaults to the current
system time regardless the fact that the field is empty or not

I there anything I am making wrong



On Wed, Sep 24, 2014 at 12:19 PM, Leonel Câmara 
wrote:

> Put it as a placeholder?
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/AHiFwg2tZ4I/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


[web2py] Re: How can I set correctly auth.settings.registration_requires_verification = False ?

2014-08-27 Thread Luca Guerrieri
Hi people,

please do you have any idea on the way i can avoid the register_key 
verification ?
Thank You


Il giorno lunedì 4 agosto 2014 10:39:26 UTC+2, Luca Guerrieri ha scritto:
>
> Goodmornig people,
> I've customized registration form and relative view, for integrating the 
> registration
> process with Active Directory (asap I'll post on webslices my results :-) )
> But ... I've a problem ... and I'm not able to resolve correctly ...
>
> in db.pt I've set 
>
> ## configure auth policy
> auth.settings.registration_requires_verification = False
> auth.settings.registration_requires_approval = False
> auth.settings.reset_password_requires_verification = True
>
> so it means that if a new user registers after submit he will be able to 
> make login without register_key verification etc... right?
>
> it seems it's not so  after registration I've the registration_key 
> filled with the key and I've to clear if i want to permit loging 
> to the user ...
>
> What is wrong ?
>
>
> Thank you for your help 
>
> Luca
>
>

-- 
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: How can I set correctly auth.settings.registration_requires_verification = False ?

2014-08-07 Thread Luca Guerrieri
 
user_attrs['otherTelephone'] = ''user_attrs['wWWHomePage'] = 
form.vars.f_wwwuser_attrs['url'] = ''#-- Address Property 
Pageuser_attrs['streetAddress'] = form.vars.f_address
user_attrs['postOfficeBox'] = ''user_attrs['l'] = 
form.vars.f_city#user_attrs['st'] = form.vars.stateoffice
user_attrs['postalcode'] = form.vars.f_zipcodeuser_attrs['c'] = 
form.vars.f_country#-- Organization Property Page
user_attrs['title'] = form.vars.f_jobtitleuser_attrs['department'] 
= form.vars.f_departementuser_attrs['company'] = 
form.vars.f_organization#-- Telephones Property Page
user_attrs['homephone'] = ''user_attrs['otherhomephone'] = 
''user_attrs['pager'] = ''user_attrs['otherpager'] = 
''user_attrs['mobile'] = form.vars.f_mobile
user_attrs['othermobile'] = ''user_attrs['ipPhone'] = 
form.vars.f_IMuser_attrs['facsimiletelephonenumber'] = 
form.vars.f_faxuser_attrs['otherfacsimiletelephonenumber'] = 
''user_attrs['ipphone'] = ''user_attrs['otheripphone'] = 
''user_attrs['info'] = form.vars.f_infouser_ldif = 
modlist.addModlist(user_attrs)# Prepare the password
unicode_pass = unicode('\"' + str(form.vars.password_two) + '\"', 
'iso-8859-1')password_value = 
unicode_pass.encode('utf-16-le')add_pass = [(ldap.MOD_REPLACE, 
'unicodePwd', [password_value])]# 512 will set user account to 
enabledmod_acct = [(ldap.MOD_REPLACE, 'userAccountControl', 
'512')]# New group membershipadd_member = [(ldap.MOD_ADD, 
'member', user_dn)]# Add the new user account
try:con.add_s(user_dn, user_ldif)except ldap.LDAPError, 
error_message:session.flash = T("Error adding new user: %s" % 
error_message)redirect(URL('result'))## Add the 
passwordtry:con.modify_s(user_dn, add_pass)
except ldap.LDAPError, error_message:session.flash =  T("Error 
setting password: %s" % error_message)redirect(URL('result'))   
 ## Change the account back to enabledtry:
con.modify_s(user_dn, mod_acct)except ldap.LDAPError, 
error_message:session.flash =  T("Error enabling user: %s" % 
error_message)redirect(URL('result'))## Add user to 
their primary grouptry:con.modify_s(GROUP_DN, 
add_member)except ldap.LDAPError, error_message:
session.flash =  T("Error adding user to group: %s" % 
error_message)redirect(URL('result'))## Add user to 
their secondary grouptry:con.modify_s(ADMIN_DN, 
add_member)except ldap.LDAPError, error_message:
session.flash =  T("Error adding user to group Administrators: %s" % 
error_message)redirect(URL('result'))## Add user to 
their third group#try:#con.modify_s(DOMAIN_ADMIN_DN, 
add_member)#except ldap.LDAPError, error_message:#   
 session.flash =  T("Error adding user to group Administrators: %s" % 
error_message)#redirect(URL('result'))
con.unbind_s()response.flash =  "Form filled and submitted 
successfully"return dict(form=form)*

Il giorno lunedì 4 agosto 2014 10:39:26 UTC+2, Luca Guerrieri ha scritto:
>
> Goodmornig people,
> I've customized registration form and relative view, for integrating the 
> registration
> process with Active Directory (asap I'll post on webslices my results :-) )
> But ... I've a problem ... and I'm not able to resolve correctly ...
>
> in db.pt I've set 
>
> ## configure auth policy
> auth.settings.registration_requires_verification = False
> auth.settings.registration_requires_approval = False
> auth.settings.reset_password_requires_verification = True
>
> so it means that if a new user registers after submit he will be able to 
> make login without register_key verification etc... right?
>
> it seems it's not so  after registration I've the registration_key 
> filled with the key and I've to clear if i want to permit loging 
> to the user ...
>
> What is wrong ?
>
>
> Thank you for your help 
>
> Luca
>
>

-- 
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: How can I set correctly auth.settings.registration_requires_verification = False ?

2014-08-07 Thread Luca Guerrieri
Ops sorry, here the code ... 

 

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *Overload of the Auth_user table : ## Auth custom fields 
> auth.settings.everybody_group_id = 1 
> auth.settings.extra_fields['auth_user']= [ Field('username', 
> type='string', label=T('Username')), Field('f_role', type='integer', 
> default=2, label=T('Role')), Field('f_group', type='integer', 
> default=20, label=T('Group'), writable=False, readable=False), 
> Field('f_jobtitle', length=30, default='',label=T('Job title')), 
> Field('f_description', length=255, default='Description of your 
> duties',label=T('Description')), Field('f_organization', length=30, 
> default='',label=T('Organization')), Field('f_departement', length=30, 
> default='',label=T('Departement')), Field('f_office', length=50, 
> default='',label=T('Office')), Field('f_unit', type='string', 
> label=T('Unit')), Field('f_address', type='string', 
> label=T('Address')), Field('f_zipcode', type='string', label=T('Postal 
> Code')), Field('f_city', type='string', label=T('City')), 
> Field('f_country', db.t_countries, label=T('Country')), 
> Field('f_phone', type='string', label=T('Phone')), Field('f_fax', 
> type='string', label=T('Fax')), Field('f_mobile', type='string', 
> label=T('Mobile')), Field('f_nationality', db.t_countries, 
> label=T('Nationality')), Field('f_www', length=30, 
> default='Organization website',label=T('Website')), Field('f_info', 
> type='text', default='Other useful info not expressed in the above fields', 
> readable=False, label=T('Info')), ]Definition of a new  register method :*
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *if not session.USR: session.USR="" def register(): #Istantiate 
> the form db.auth_user['f_avatar'].readable = 
> db.auth_user['f_avatar'].writable = False form=auth.register() 
> #Importing and setup libraries from selmdap_settings import * 
> import sys try: import ldap import ldap.modlist as 
> modlist ldap.set_option(ldap.OPT_REFERRALS, 0)
>  ldap.set_option(ldap.OPT_PROTOCOL_VERSION, 3) #MS integration
>  ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)#MS 
> integration except Exception, e: logging.error('missing ldap, 
> try "easy_install python-ldap"') #raise e #If form submitted 
> if form.process().accepted: response.flash = 'form accepted' 
> #Create a new user account in Active Directory and assigns it to 
> differents groups # LDAP connection try: con = 
> ldap.initialize(LDAP_SERVER)
>  con.set_option(ldap.OPT_X_TLS,ldap.OPT_X_TLS_DEMAND)#MS integration
>  con.set_option( ldap.OPT_X_TLS_DEMAND, True )#MS integration
>  con.set_option( ldap.OPT_DEBUG_LEVEL, 255 )#MS integration
>  con.simple_bind_s(BIND_DN, BIND_PASS) except ldap.LDAPError, 
> error_message: session.flash = T("Error connecting to LDAP 
> server: %s" % error_message) redirect(URL('result'))
>  # Lets build our user: Disabled to start (514) user_dn = 'cn=' + 
> form.vars.first_name + ' ' + form.vars.last_name + ',' + BASE_DN 
> user_attrs = {} user_attrs['objectClass'] = ['top', 'person', 
> 'organizationalPerson', 'user'] user_attrs['cn'] = 
> form.vars.first_name + ' ' + form.vars.last_name #-- Account 
> Property Page user_attrs['userPrincipalName'] = session.USR + '@' + 
> DOMAIN user_attrs['sAMAccountName'] = session.USR 
> user_attrs['userAccountControl'] = '514' #-- General Property Page 
> user_attrs['givenName'] = form.vars.first_name 
> user_attrs['sn'] = form.vars.last_name user_attrs['initials'] = '' 
> user_attrs['displayName'] = form.vars.first_name + ' ' + 
> form.vars.last_name user_attrs['description'] = 
> form.vars.f_description user_attrs['physicalDeliveryOfficeName'] = 
> form.vars.f_office user_attrs['mail'] = form.vars.email 
> user_attrs['telephonenumber'] = form.vars.f_phone 
> user_attrs['otherTelephone'] = '' user_attrs['wWWHomePage'] = 
> form.vars.f_www user_attrs['url'] = '' #-- Address Property 
> Page user_attrs['streetAddress'] = form.vars.f_address 
> user_attrs['postOfficeBox'] = '' user_attrs['l'] = form.vars.f_city 
> #user_attrs['st'] = form.vars.stateoffice 
> user_attrs['postalcode'] = form.vars.f_zipcode user_attrs['c'] = 
> form.vars.f_country #-- Organization Property Page 
> user_attrs['title'] = form.vars.f_jobtitle

[web2py] Re: How can I set correctly auth.settings.registration_requires_verification = False ?

2014-08-07 Thread Luca Guerrieri


























*Overload of the Auth_user table : ## Auth custom fields 
auth.settings.everybody_group_id = 1 
auth.settings.extra_fields['auth_user']= [ Field('username', 
type='string', label=T('Username')), Field('f_role', type='integer', 
default=2, label=T('Role')), Field('f_group', type='integer', 
default=20, label=T('Group'), writable=False, readable=False), 
Field('f_jobtitle', length=30, default='',label=T('Job title')), 
Field('f_description', length=255, default='Description of your 
duties',label=T('Description')), Field('f_organization', length=30, 
default='',label=T('Organization')), Field('f_departement', length=30, 
default='',label=T('Departement')), Field('f_office', length=50, 
default='',label=T('Office')), Field('f_unit', type='string', 
label=T('Unit')), Field('f_address', type='string', 
label=T('Address')), Field('f_zipcode', type='string', label=T('Postal 
Code')), Field('f_city', type='string', label=T('City')), 
Field('f_country', db.t_countries, label=T('Country')), 
Field('f_phone', type='string', label=T('Phone')), Field('f_fax', 
type='string', label=T('Fax')), Field('f_mobile', type='string', 
label=T('Mobile')), Field('f_nationality', db.t_countries, 
label=T('Nationality')), Field('f_www', length=30, 
default='Organization website',label=T('Website')), Field('f_info', 
type='text', default='Other useful info not expressed in the above fields', 
readable=False, label=T('Info')), ]Definition of a new  register method :*
































































































































*if not session.USR: session.USR="" def register(): #Istantiate the 
form db.auth_user['f_avatar'].readable = 
db.auth_user['f_avatar'].writable = False form=auth.register() 
#Importing and setup libraries from selmdap_settings import * 
import sys try: import ldap import ldap.modlist as 
modlist ldap.set_option(ldap.OPT_REFERRALS, 0)
 ldap.set_option(ldap.OPT_PROTOCOL_VERSION, 3) #MS integration
 ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)#MS 
integration except Exception, e: logging.error('missing ldap, 
try "easy_install python-ldap"') #raise e #If form submitted 
if form.process().accepted: response.flash = 'form accepted' 
#Create a new user account in Active Directory and assigns it to 
differents groups # LDAP connection try: con = 
ldap.initialize(LDAP_SERVER)
 con.set_option(ldap.OPT_X_TLS,ldap.OPT_X_TLS_DEMAND)#MS integration
 con.set_option( ldap.OPT_X_TLS_DEMAND, True )#MS integration
 con.set_option( ldap.OPT_DEBUG_LEVEL, 255 )#MS integration
 con.simple_bind_s(BIND_DN, BIND_PASS) except ldap.LDAPError, 
error_message: session.flash = T("Error connecting to LDAP 
server: %s" % error_message) redirect(URL('result'))
 # Lets build our user: Disabled to start (514) user_dn = 'cn=' + 
form.vars.first_name + ' ' + form.vars.last_name + ',' + BASE_DN 
user_attrs = {} user_attrs['objectClass'] = ['top', 'person', 
'organizationalPerson', 'user'] user_attrs['cn'] = 
form.vars.first_name + ' ' + form.vars.last_name #-- Account 
Property Page user_attrs['userPrincipalName'] = session.USR + '@' + 
DOMAIN user_attrs['sAMAccountName'] = session.USR 
user_attrs['userAccountControl'] = '514' #-- General Property Page 
user_attrs['givenName'] = form.vars.first_name 
user_attrs['sn'] = form.vars.last_name user_attrs['initials'] = '' 
user_attrs['displayName'] = form.vars.first_name + ' ' + 
form.vars.last_name user_attrs['description'] = 
form.vars.f_description user_attrs['physicalDeliveryOfficeName'] = 
form.vars.f_office user_attrs['mail'] = form.vars.email 
user_attrs['telephonenumber'] = form.vars.f_phone 
user_attrs['otherTelephone'] = '' user_attrs['wWWHomePage'] = 
form.vars.f_www user_attrs['url'] = '' #-- Address Property 
Page user_attrs['streetAddress'] = form.vars.f_address 
user_attrs['postOfficeBox'] = '' user_attrs['l'] = form.vars.f_city 
#user_attrs['st'] = form.vars.stateoffice 
user_attrs['postalcode'] = form.vars.f_zipcode user_attrs['c'] = 
form.vars.f_country #-- Organization Property Page 
user_attrs['title'] = form.vars.f_jobtitle user_attrs['department'] 
= form.vars.f_departement user_attrs['company'] = 
form.vars.f_organization #-- Telephones Property Page 
user_attrs['homephone'] = '' user_attrs['otherhomephone'] = '' 
user_attrs['pager'] = '' user_attrs['otherpager'] = '' 
   

[web2py] How can I set correctly auth.settings.registration_requires_verification = False ?

2014-08-04 Thread Luca Guerrieri
Goodmornig people,
I've customized registration form and relative view, for integrating the 
registration
process with Active Directory (asap I'll post on webslices my results :-) )
But ... I've a problem ... and I'm not able to resolve correctly ...

in db.pt I've set 

## configure auth policy
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True

so it means that if a new user registers after submit he will be able to 
make login without register_key verification etc... right?

it seems it's not so  after registration I've the registration_key 
filled with the key and I've to clear if i want to permit loging 
to the user ...

What is wrong ?


Thank you for your help 

Luca

-- 
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 and custom edit form

2014-02-21 Thread Luca Guerrieri
mmmh... sorry Anthony but you know i'm new on web2py... can you show me more in 
deep this your last? 
thank you
lucs

-- 
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: SQLFORM.grid and custom edit form

2014-02-21 Thread Luca Guerrieri
mmmh... sorry Anthony but you know i'm new on web2py... can you show me more in 
deep this your last? 
thank you
lucs

-- 
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: SQLFORM.grid and custom edit form

2014-02-21 Thread Luca Guerrieri
mmmh... sorry Anthony but you know i'm new on web2py... can you show me more in 
deep this your last? 
thank you
lucs

-- 
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: SQLFORM.grid and custom edit form

2014-02-21 Thread Luca Guerrieri
Looks like it's my tie to post an answer :-))

To customize the edit form or new form in a SQLFORM.grid i put in the 
controller, but exactly 
before the sqlform.grid creation and with a return ...

if request.args(0) in ['edit']: 
response.flash=T("Edit form")
response.view = 'default/editclist.html' 
form = SQLFORM(db.mylist, db.mylist(request.args(2)))
if form.process().accepted:
response.flash = 'Update form accepted'
elif form.errors:
response.flash = 'Update form rejected, there are errors'
return dict(form=form)

in this way I can have an edit or whatever i need ... customized ...

p.s.: now I'm fighting with a links=links customization ... but this is 
another question :-))
 

Il giorno giovedì 20 febbraio 2014 16:35:17 UTC+1, Luca Guerrieri ha 
scritto:
>
> Dear all,
> after some new things i have understood on web2py I'm not able to find 
> this solution :
>
> I've a sqlform.grid which becomes from a 2 tables query 
>
> ... some customization code 
>
> form = SQLFORM.grid(query=query, left = db.mylist.on(db.person.id == 
> db.mylist.name ) , field_id = (db.mylist.id), fields=fields, 
> headers=headers, orderby=default_sort_order, create=False, deletable=False, 
> editable=True, showbuttontext=False, maxtextlength=64, paginate=100, 
> user_signature=False, searchable = True, details = True)
>
>
>
> db.define_table('person',
> Field('name', 'string'),
> Field('dob', length=10),
> Field('address', 'text', length=255),
> Field('countryname'),
> )
>
> db.define_table('mylist',
> Field('object', 'string', length=6, required=True),
> Field('name', db.person),
> Field('zip', length=5, required=False),
> )
>
> When i click on the edit button related to a row (the pencil at the end of 
> every record row) , I would edit that values through a form on which i can 
> find 
> the values viewed in the row. That is possible for all the values become 
> from the first table (cardlist) but not for that become from the second 
> table (person)
>
> precisely i can read the ID of the second table but not the value referred 
> to 
> eg : editing the row I have a form with : object, zip and instead the name 
> of the person its id ...
>  
> There is a way to customize the edit form connected to the sqlform.grid 
> item ?
>
> Thank You
>
>
>

-- 
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] SQLFORM.grid and custom edit form

2014-02-20 Thread Luca Guerrieri
Dear all,
after some new things i have understood on web2py I'm not able to find this 
solution :

I've a sqlform.grid which becomes from a 2 tables query 

... some customization code 

form = SQLFORM.grid(query=query, left = db.mylist.on(db.person.id == 
db.mylist.name ) , field_id = (db.mylist.id), fields=fields, 
headers=headers, orderby=default_sort_order, create=False, deletable=False, 
editable=True, showbuttontext=False, maxtextlength=64, paginate=100, 
user_signature=False, searchable = True, details = True)



db.define_table('person',
Field('name', 'string'),
Field('dob', length=10),
Field('address', 'text', length=255),
Field('countryname'),
)

db.define_table('mylist',
Field('object', 'string', length=6, required=True),
Field('name', db.person),
Field('zip', length=5, required=False),
)

When i click on the edit button related to a row (the pencil at the end of 
every record row) , I would edit that values through a form on which i can 
find 
the values viewed in the row. That is possible for all the values become 
from the first table (cardlist) but not for that become from the second 
table (person)

precisely i can read the ID of the second table but not the value referred 
to 
eg : editing the row I have a form with : object, zip and instead the name 
of the person its id ...
 
There is a way to customize the edit form connected to the sqlform.grid 
item ?

Thank You


-- 
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] Insert on related tables by code

2014-02-16 Thread Luca Guerrieri
Goodmorning,
i:m trying to fill a table record by code. All the basic test went good,but now 
i'm trying to fill a table that has a field wich is a foreign key of another.
luca
field ('name', db.person)
whrn i try to fill i catch an error .
. in which way i can compose my instruction 
for do it? 
thank you in advance x you patience
luca

-- 
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: HTML Parser of uploaded file

2014-02-15 Thread Luca Guerrieri
Infact ... my first problem is to retrieve the file ... 
@Anthony
I would catch the file content during the upload (or near that moment) but 
I wasn't able to do it ...

@Leonel
Yes... I tried it and effectively it's better than internal HTML parser 
(TAG and other stuff) ... 

@All 
How can I read the file without take it from the file system ?


Il giorno venerdì 14 febbraio 2014 15:31:26 UTC+1, Anthony ha scritto:
>
> Why are you using the custom store and retrieve methods? Note, looks like 
> you might be vulnerable to a directory traversal attack (depending on 
> whether you're validating the "filename" argument passed to the retrieve 
> function).
>
> Anthony
>
> On Friday, February 14, 2014 5:21:40 AM UTC-5, Luca Guerrieri wrote:
>>
>> Goodmorning people,
>> I'm teaching myself web2py and I've a little question for understanding 
>> how can i do ...
>>
>> I've a form (becomes from a table) with an upload field
>> i would to upload an html file and I would to parse it in the mean time 
>> .. or just after the completition of the operation...
>>
>> eg.: after i've clicked on the submit button so i would import the file 
>> and after the parsing filling a new table with the results of the html 
>> parse operation.
>>
>> my table :
>>
>> db.define_table("files",
>> Field("name", unique=True),
>> Field('country', requires=IS_IN_DB(db, 
>> 'country.printable_name')),
>> Field("files", "upload", custom_store=store_file, 
>> custom_retrieve=retrieve_file)
>> )
>>
>> I used (thanks to web2py group experts) these two function for storing 
>> and renaming the file uploaded :
>>
>> def store_file(file, filename=None, path=None):
>> path = "applications/myappuploads"
>> if not os.path.exists(path):
>>  os.makedirs(path)
>> pathfilename = os.path.join(path, filename)
>> dest_file = open(pathfilename, 'wb')
>> try:
>> shutil.copyfileobj(file, dest_file)
>> finally:
>> dest_file.close()
>> return filename
>>
>> def retrieve_file(filename, path=None):
>> path = "applications/myapp/uploads"
>> return (filename, open(os.path.join(path, filename), 'rb')) 
>>
>> after I've connected in my display_form()  all the things ...
>>
>> def display_form():
>> if len(request.args):
>> form=SQLFORM(db.files, request.args[0], upload=URL("download"))
>> else:
>> form=SQLFORM(db.files, upload=URL("download"))
>> txt_content=[]
>> if form.process(onvalidation=validate).accepted:
>> content=StringIO.StringIO(data)
>> msg = process_file(content)
>> response.flash = T(msg)
>> elif form.errors:
>> response.flash = T('some errors occurred')
>> else:
>> pass
>> return {"form":form}
>>
>> I validate the uploaded file giving the name that i've put in the field 
>> "name"
>>
>> def validate(form):
>> if form.vars.files is not None:
>> form.vars.files.filename = form.vars.name + ".html"
>>
>> and my process_file is : 
>>
>> def process_file(content):
>> all_lines = content
>> msg = 'content not processed'
>> for line in all_lines:
>> try:
>> msg = 'processed succesfully'
>> except:
>> msg = 'error processing'
>> return msg
>>
>> here i've my problems  in which way I can parse the html file, with 
>> which html parser ?
>>
>> Thank you in advance 
>> Luca
>>
>>
>>

-- 
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] HTML Parser of uploaded file

2014-02-14 Thread Luca Guerrieri
Goodmorning people,
I'm teaching myself web2py and I've a little question for understanding how 
can i do ...

I've a form (becomes from a table) with an upload field
i would to upload an html file and I would to parse it in the mean time .. 
or just after the completition of the operation...

eg.: after i've clicked on the submit button so i would import the file and 
after the parsing filling a new table with the results of the html parse 
operation.

my table :

db.define_table("files",
Field("name", unique=True),
Field('country', requires=IS_IN_DB(db, 
'country.printable_name')),
Field("files", "upload", custom_store=store_file, 
custom_retrieve=retrieve_file)
)

I used (thanks to web2py group experts) these two function for storing and 
renaming the file uploaded :

def store_file(file, filename=None, path=None):
path = "applications/myappuploads"
if not os.path.exists(path):
 os.makedirs(path)
pathfilename = os.path.join(path, filename)
dest_file = open(pathfilename, 'wb')
try:
shutil.copyfileobj(file, dest_file)
finally:
dest_file.close()
return filename

def retrieve_file(filename, path=None):
path = "applications/myapp/uploads"
return (filename, open(os.path.join(path, filename), 'rb')) 

after I've connected in my display_form()  all the things ...

def display_form():
if len(request.args):
form=SQLFORM(db.files, request.args[0], upload=URL("download"))
else:
form=SQLFORM(db.files, upload=URL("download"))
txt_content=[]
if form.process(onvalidation=validate).accepted:
content=StringIO.StringIO(data)
msg = process_file(content)
response.flash = T(msg)
elif form.errors:
response.flash = T('some errors occurred')
else:
pass
return {"form":form}

I validate the uploaded file giving the name that i've put in the field 
"name"

def validate(form):
if form.vars.files is not None:
form.vars.files.filename = form.vars.name + ".html"

and my process_file is : 

def process_file(content):
all_lines = content
msg = 'content not processed'
for line in all_lines:
try:
msg = 'processed succesfully'
except:
msg = 'error processing'
return msg

here i've my problems  in which way I can parse the html file, with 
which html parser ?

Thank you in advance 
Luca


-- 
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] Ajax function

2013-11-13 Thread Luca Dalla Palma

Hello,
this is my *view*


on the *controller *I build a function containing the folowing code:

pippone='ciao'
stringa.append("jQuery('#paginatore').html('%s');" % pippone())
print pippone
return stringa

The console says
ciao
(the HTML generated appears to be right)

When the function returns, I expect the new anchor to appear in the 
"paginatore" div, but it doesn't. Anybody can suggest me why?

-- 
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: Web2py (2.7.4) not working on IE9

2013-11-11 Thread Luca Zacchetti
Yes, that was a cookies problem.
IE was blocking all cookies by default, I had to set a lower cookies policy 
in Internet options->Privacy.


Il giorno venerdì 8 novembre 2013 17:44:02 UTC+1, Luca Zacchetti ha scritto:
>
> Web2py (version 2.7.4) forms are not working on my IE9 browser.
> Just tried with a "fresh" web2py installation and even the form to access 
> to web2py admin interface is not working, it reloads itself without doing 
> the "login" and every other forms in my app is doing the same.
>
> Do you also have this kind of problem? How can I Fix it?
>
> 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] Web2py (2.7.4) not working on IE9

2013-11-08 Thread Luca Zacchetti
Web2py (version 2.7.4) forms are not working on my IE9 browser.
Just tried with a "fresh" web2py installation and even the form to access 
to web2py admin interface is not working, it reloads itself without doing 
the "login" and every other forms in my app is doing the same.

Do you also have this kind of problem? How can I Fix it?

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] Alias on Fields

2013-10-25 Thread Luca Dalla Palma
Hello Sirs,
I access a customer Db with two tables as follows:

db.define_table('events',
Field('event_id', type='integer'),
primarykey=['event_id'])

db.define_table('documents',
Field('document_id'),
Field('event_id', 'reference events')
primarykey=['document_id'])

I would like to left join together. If I use the following expression:

rows = db(db.events.event_id==db.documents.event_id).select()

I obtain the following error=ORA-00918: column ambiguously defined
Is there a way to alias one of the two "event_id" fileds in order to make 
the join to work?

Thank you, best regards.

-- 
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: Active/Ldap directory and Group restrictions access

2013-09-24 Thread Luca Guerrieri
Thank you Camille,

finally I've found a solution and i'v written a little how to on 
web2pyslices

http://www.web2pyslices.com/slice/show/1715/authentication-and-group-control-with-active-directory-ldap

Luca

Il giorno domenica 15 settembre 2013 20:09:01 UTC+2, Luca Guerrieri ha 
scritto:
>
> Hi people,
> i'm developing an application with web2py (very awesome project) and I'm 
> able to bind it with an AD server (also with a Samba as AD) 
> I'm able to restrict the login chain to the ldap users but I'm not able to 
> define then to restrict, e.g.. for a page, the access to a particular group 
> defined into the ldap tree ... 
>
> so, if i've ou=MyOU and inside 2 groups Group1 and Group2and I've 2 pages 
> PageGroup1 and PageGroup2 in which way I can auth the access 
> for every group to its respective page ? 
>
> Thank you in advance 
>
> Luca
>
>
>

-- 
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] Active/Ldap directory and Group restrictions access

2013-09-15 Thread Luca Guerrieri
Hi people,
i'm developing an application with web2py (very awesome project) and I'm 
able to bind it with an AD server (also with a Samba as AD) 
I'm able to restrict the login chain to the ldap users but I'm not able to 
define then to restrict, e.g.. for a page, the access to a particular group 
defined into the ldap tree ... 

so, if i've ou=MyOU and inside 2 groups Group1 and Group2and I've 2 pages 
PageGroup1 and PageGroup2 in which way I can auth the access 
for every group to its respective page ? 

Thank you in advance 

Luca


-- 
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: A few website projects built in Web2py

2013-08-15 Thread Luca
I suspect the author forgot to change the permissions to public. -Luca

On Thursday, August 15, 2013 4:56:52 PM UTC-7, samuel bonill wrote:
>
> hey man !! 
>
> the github links are broken !!
>
> El lunes, 12 de agosto de 2013 19:12:14 UTC-5, leaping...@gmail.comescribió:
>>
>> I built these sites a while ago and figured I would release them. They 
>> weren't for clients, more personal projects. 
>>
>> https://github.com/techshinobi/free-business-pages
>> https://github.com/techshinobi/echovids
>>
>> The echovids project is a bit older but free-business-pages is a newer 
>> one. Can't give to much of an online example of either of these. But here 
>> is www.free-business-pages.com
>>
>> Thanks for your time
>>
>> Maybe some one can find some use for them. free-business-pages uses 
>> paypal and has a paypal subscription service, thanks to Bruna Rocha for a 
>> video tutorial of his which I came across on using Paypal/Web2py :D 
>> Echovids you can schedule a time for a TV show to play between. You can 
>> specify the time zone in the code.
>>
>> Anyway *cheers
>>
>>

-- 

--- 
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: deployment to google app engine did not include my static files

2013-08-14 Thread Luca
Massimo, I have been trying to send you emails for some time without 
success.  Is there some issue with your email? 
Luca

On Tuesday, August 13, 2013 7:15:57 AM UTC-7, Massimo Di Pierro wrote:
>
> email it to me please or post a patch on github.
>
> On Monday, 12 August 2013 19:03:59 UTC-5, Luca wrote:
>>
>> Shall I post a working app.yaml (minus confidential details) that works 
>> with threadsafe=True? 
>> Let me know if this would help.
>> Luca
>>
>> On Sunday, August 4, 2013 12:12:16 PM UTC-7, davedigerati wrote:
>>>
>>> as you can see from here: http://sportssquaresonline.appspot.com/
>>> it did upload most of the static files, specifically 30, but the ones I 
>>> added, both images and a css file, it did not.
>>> any idea why???
>>>
>>> deployed both through the web2py admin feature and the GAE Launcher
>>>
>>>

-- 

--- 
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] Has the format of the auth tables changed recently? Or the format of t

2013-08-14 Thread Luca
I have recently upgraded from web2py release R-2.4.6 to the head of the 
branch. 
I am using web2py on appengine, using: 

from gluon.contrib.memdb import MEMDB
from google.appengine.api.memcache import Client
session.connect(request, response, db = MEMDB(Client()))


I also have the following code in db.py, to monitor db performance: 

def log_db(action): 
d = action() 
logger.info(repr(db._timings)) 
return d

response._caller = log_db


When trying to login, using a session cookie that might have been set 
before the update, I got the error below.  It happened systematically, 
whenever I tried to log in. 
Then, I downgraded to the older web2py R-2.4.6 release, logged in, then 
out, and reupgraded to the newest release, and the error went away. 
 Does anyone have any suggestions as to why this might be the case?  Has 
the logging mechanism changed?  Have the auth tables changed? 
Also, should this error be caught by web2py and handled in a more graceful 
way? 

Luca

  File 
"/home/luca/work/web2py-crowdrank/applications/crowdgrader/models/db.py", 
line 220, in log_db
d = action()
  File 
"/home/luca/work/web2py-crowdrank/applications/crowdgrader/controllers/default.py",
 
line 31, in user
return dict(form=auth())
  File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 1293, in 
__call__
return getattr(self, args[0])()
  File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 2253, in 
login
self.login_user(user)
  File "/home/luca/work/web2py-crowdrank/gluon/tools.py", line 1874, in 
login_user
db=sessdb
  File "/home/luca/work/web2py-crowdrank/gluon/globals.py", line 739, in 
renew
    row = db(table.id == record_id).select()
  File "/home/luca/work/web2py-crowdrank/gluon/contrib/memdb.py", line 327, 
in __eq__
return Query(self, '=', value)
  File "/home/luca/work/web2py-crowdrank/gluon/contrib/memdb.py", line 507, 
in __init__
id=long(right))
ValueError: invalid literal for long() with base 10: 'None'


-- 

--- 
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 on Google Drive

2013-08-13 Thread Luca
If you use sqlite, it should work, since the db is kept in a local file. 
Luca

On Tuesday, August 13, 2013 12:11:37 PM UTC-7, Derek wrote:
>
> If you are going to manually sync up the databases, use the 'sql.log' to 
> make your work easier.
>
> On Tuesday, August 13, 2013 12:10:23 PM UTC-7, Derek wrote:
>>
>> In this scenario, your database files keep track of the current state of 
>> the database. So this won't really work unless you manually sync up the 
>> databases.
>>
>> You may want to try fake_migrate to rebuild those table files.
>> http://www.web2py.com/book/default/chapter/06#Fixing-broken-migrations
>>
>> On Tuesday, August 13, 2013 10:29:50 AM UTC-7, Evan Caldwell wrote:
>>>
>>> Johann, 
>>>
>>> I didn't realize you had responded. I am using MySQL and getting the 
>>> error : no such table: auth_user
>>>
>>>
>>> On Thursday, August 8, 2013 1:41:52 AM UTC-6, Johann Spies wrote:
>>>>
>>>> On 08/08/2013 01:10, Evan Caldwell wrote: 
>>>> > I use Google Drive on all my machines to keep things synced up. I 
>>>> > installed web2py on my windows laptop in a folder in my Google Drive 
>>>> > (I use the windows client). Then I opened up web2py on my windows 
>>>> > machine at work from the same synced folder. I can open up the admin 
>>>> > page an all but when I open a page that tries to access the database 
>>>> I 
>>>> > get errors. I'm sure there is a good reason but I'm kind of a noob 
>>>> and 
>>>> > learning web development via web2py so any help is much appreciated. 
>>>> -- 
>>>> Which database do you use? 
>>>> What do the errors tell you? 
>>>>
>>>> Regards 
>>>> Johann 
>>>>
>>>> -- 
>>>> Johann SpiesTelefoon: 021-808 4699 
>>>> Databestuurder /  Data managerFaks: 021-883 3691 
>>>>
>>>> Sentrum vir Navorsing oor Evaluasie, Wetenskap en Tegnologie 
>>>> Centre for Research on Evaluation, Science and Technology 
>>>> Universiteit Stellenbosch. 
>>>>
>>>>   "Rest in the LORD, and wait patiently for him: fret not 
>>>>thyself because of him who prospereth in his way, 
>>>>because of the man who bringeth wicked devices to pass." 
>>>>  Psalms 37:7 
>>>>
>>>> E-pos vrywaringsklousule 
>>>>
>>>> Hierdie e-pos mag vertroulike inligting bevat en mag regtens 
>>>> geprivilegeerd wees en is slegs bedoel vir die persoon aan wie dit 
>>>> geadresseer is. Indien u nie die bedoelde ontvanger is nie, word u hiermee 
>>>> in kennis gestel dat u hierdie dokument geensins mag gebruik, versprei of 
>>>> kopieer nie. Stel ook asseblief die sender onmiddellik per telefoon in 
>>>> kennis en vee die e-pos uit. Die Universiteit aanvaar nie aanspreeklikheid 
>>>> vir enige skade, verlies of uitgawe wat voortspruit uit hierdie e-pos 
>>>> en/of 
>>>> die oopmaak van enige lês aangeheg by hierdie e-pos nie. 
>>>>
>>>> E-mail disclaimer 
>>>>
>>>> This e-mail may contain confidential information and may be legally 
>>>> privileged and is intended only for the person to whom it is addressed. If 
>>>> you are not the intended recipient, you are notified that you may not use, 
>>>> distribute or copy this document in any manner whatsoever. Kindly also 
>>>> notify the sender immediately by telephone, and delete the e-mail. The 
>>>> University does not accept liability for any damage, loss or expense 
>>>> arising from this e-mail and/or accessing any files attached to this 
>>>> e-mail. 
>>>>
>>>

-- 

--- 
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: Request: Course about Web2py & TDD + pledge for cash

2013-08-13 Thread Luca
Dear Michael, 

last year's class web page is here, and all is accessible mostly by 
everybody.  There may be videos that, as they include students and did not 
have all permissions, are accessible only from UCSC, but the rest should be 
wide open. 
This year will be similar, perhaps with more emphasis on angular. 

https://sites.google.com/a/ucsc.edu/luca/classes/cmps-183-hypermedia-and-the-web/cmps-183-fall-2012

Luca

On Monday, August 12, 2013 7:23:08 PM UTC-7, Michael Herman wrote:
>
> I'd love to hear more about your curriculum that you're going to be 
> teaching. I wrote the course Real Python for the Web @ RealPython.com. I'd 
> love to compare notes. :)
>  
>
> On Mon, Aug 12, 2013 at 6:53 PM, Luca  >wrote:
>
>> I will be teaching a web dev class at UCSC based on web2py, and I may 
>> make the videos available in YouTube.  
>> Starting around September 20. 
>> Email me if you are interested - lu...@ucsc.edu 
>>
>> Thanks! -Luca
>>
>> On Sunday, August 11, 2013 10:29:46 AM UTC-7, Mika Sjöman wrote:
>>>
>>> Hi
>>>
>>> I am trying to get started with TDD and web2py, but it is really hard 
>>> since I do not have a CS degree. I have been studying this two courses at 
>>> Coursera, and especially the former is awesome (I did not like the Intro to 
>>> Systematic program design so much)
>>>
>>> https://class.coursera.org/**programming2-001/<https://class.coursera.org/programming2-001/>
>>>   # LTHP How to write quality code - awesome!
>>> https://class.coursera.org/**programdesign-001/class/index<https://class.coursera.org/programdesign-001/class/index>
>>>  #Systematic program design
>>>
>>> I just wanted to say that if anyone out there is thinking of writing a 
>>> book or video course, I would certainly pay for it! Preferably a Udemy 
>>> course that shows how to do functional testing, unit testing, front end 
>>> Selenium, integration testing, proper cashing techniques for fast webites 
>>> etc. Preferably with TDD or some other framework, building lets say 3 to 4 
>>> small simple projects from scratch. 
>>>
>>> I am really sick and tired of writing code that blows up. While web2py 
>>> gave me an awesome way to easily write code and get going, I have not made 
>>> much progress writing better quality code with web2py. I think too much 
>>> time has been spent on learning to program (the language / frameworks), 
>>> while the problem for me has always been not being able to do proper 
>>> software engineering. 
>>>
>>> So here is a pledge. If any of you good TDD programmers do a small video 
>>> course on writing web2py software with TDD, Selenium, version control etc, 
>>> then Ill be happy to chip in 50 USD for such a course. How about a 
>>> Udemy.com course? Here is the guide to get started: https://www.udemy.**
>>> com/official-udemy-instructor-**course/<https://www.udemy.com/official-udemy-instructor-course/>
>>> For inspiration about topics I really reccomend looking at that LHTP 
>>> Writing Quality Code at Coursera. 
>>>
>>>
>>> Anyone else interesting in pledging cash to learn proper software design 
>>> with Web2py? Maybe someone can make it a kickstarter?
>>>
>>  -- 
>>  
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/pNsazmC3-7k/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 

--- 
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: How to detect the browser time zone?

2013-08-12 Thread Luca
Thank you Roberto, I will look at it! 
I also found this one: https://bitbucket.org/pellepim/jstimezonedetect
The one you found is, I think, the one that was being discussed in March; I 
will definitely study it.
Luca

On Monday, August 12, 2013 7:02:30 PM UTC-7, Luca wrote:
>
> I see that the validators (such as DATETIME) take a timezone object, so 
> that the time can be stored in utc and converted to localtime. 
> However, I did not see if there is support in web2py for querying the 
> browser time zone. 
> This was discussed in this group back in March, but I did not see (or 
> could not find) the information on browser timezone detection. 
>
> Is this a plugin?  Has any solution been posted? 
>
> Many thanks!
>
> --Luca
>

-- 

--- 
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] How to detect the browser time zone?

2013-08-12 Thread Luca
I see that the validators (such as DATETIME) take a timezone object, so 
that the time can be stored in utc and converted to localtime. 
However, I did not see if there is support in web2py for querying the 
browser time zone. 
This was discussed in this group back in March, but I did not see (or could 
not find) the information on browser timezone detection. 

Is this a plugin?  Has any solution been posted? 

Many thanks!

--Luca

-- 

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

2013-08-12 Thread Luca
I generally like to split things according to function, and I don't like 
files much larger than 1000 lines, so I would split, but this is a matter 
of style.
Aside from this, you might want to see if you can reorganize your tables 
into fewer ones... 
One other thing is that I wonder if it would help to set 
migrate_enabled=False in your db.py, and only set it to True when you need. 
 Otherwise, for 100 tables, the size of the information that needs to be 
checked to determine whether a migration is needed could be large. 

Luca

On Sunday, August 11, 2013 6:45:08 AM UTC-7, Alex Glaros wrote:
>
> Is the size of a model or controller file a reason for breaking it into 
> smaller files?
>
> my default/db.py file has over 100 tables and sometimes editing it is 
> slow.  Is editing speed by itself a reason for splitting up the file?
>
> thanks,
>
> Alex
>

-- 

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

2013-08-12 Thread Luca
Did the patch from Niphlod mentioned here go live? 
I see that now validators can take a pytz object specifying the timezone. 
However, I was not able to find where the information on how to get the 
browser timezone.  Is this a plugin?

Also, am I correct to assume that the validators always return the time in 
UTC? 
I agree that this would be the best approach (given that for some timezones 
+ DST settings, there is no one-to-one correspondence between UTC and 
localtime...). 

Many thanks, 

Luca

On Sunday, March 17, 2013 7:31:24 PM UTC-7, Massimo Di Pierro wrote:
>
> I was looking at code to detect the user timezone and store dates 
> consistently in UTC format.
> I made some changes in trunk to handle this. I could use some help testing.
>
> 1) In the header of your layout.html add:
>
>  {{if not session.timezone:}}
>   
> 
> jQuery(function(){jQuery.post('{{=URL('default','set_timezone')}}',{timezone:(new
>  
> Date()).getTimezoneOffset()});});
>   
> {{pass}}
>
> 2) in the default controller:
>
> def set_timezone():
> session.timezone = int(request.vars.timezone)/60
>
> 3) Use the new timezone attribute of validators in trunk:
>
>Field('birthday','datetime',requires = 
> IS_DATETIME(timezone=session.timezone)
>
> Does it work for you? Suggestions for improvement?
>
> Massimo
>

-- 

--- 
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: How to keep database portability?

2013-08-12 Thread Luca
I may be missing something, but usually when I am in your situation I use 
an update_or_insert web2py statement, rather than explicitly managing 
transactions.  Perhaps you could also consider encoding more of your logic 
in web2py rather than postgres?  Or perhaps I am being naive? 

Luca

On Friday, August 9, 2013 9:53:22 AM UTC-7, Joe Barnhart wrote:
>
> I'm currently using Posgres as my database, but I'd like to preserve the 
> portability that web2py gives me to change databases.  I find that I need 
> to add all sorts of "idioms" in my database code and I'm running dry when 
> thinking of ways to abstract this and make a layer that allows me to use, 
> say, SQLite in place of Postgres.  Let me provide an example.
>
> When inserting data into Postgres which may collide with an existing row, 
> and for which there is a unique index, I need to bracket the insert with 
> code that sets a savepoint, tries the statement, and then either removes 
> the savepoint or rolls back the transaction.  It looks like this:
>
>
> def ignore_on_fail(token,stmt,*args,**kwargs):
> """Insert a row into the database but bracket the insert
> with a 'savepoint' and rollback to it if the statement fails"""
> from random import randint
> savepoint_name = '_'.join([token,str(randint())])
> ret = None
> db = current.db
> try:
> db.executesql('SAVEPOINT %s;'%savepoint_name)
> ret = stmt(*args,**kwargs)
> db.executesql('RELEASE %s;'%savepoint_name)
> except:
> db.executesql('ROLLBACK TO %;'%savepoint_name)
> return ret
>
>
> In SQLite, the table is built with a "ON CONFLICT IGNORE" constraint 
> resolution, so the equivalent fucntion would simply be:
>
>
> def ignore_on_fail(token,stmt,*args,**kwargs):
> """Insert a row into the database but bracket the insert
> with a 'savepoint' and rollback to it if the statement fails"""
> ret = stmt(*args,**kwargs)
> return ret
>
>
> But where to put these functions?  And how do I choose one set over the 
> other, based on something that isn't known until the "db.py" file is read? 
>  I can put these in a module and import them, but the module name must be 
> known at compile time (since these database commands are occurring in 
> modules as well) and that isn't known because the db.py file has not yet 
> been read.  My head hurts!
>
> There must be some pattern I'm missing to extend my database code so that 
> I can prevent it from being too tied to a single platform.  What pattern do 
> you use?
>
> -- Joe
>

-- 

--- 
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: Command line login

2013-08-12 Thread Luca
The correct way to do this would be something like: 

def ulogin():
u = auth.login_bare(request.vars.user, request.vars.password)
if not u: 
 return ''
else:
 return u

Or something like that; I don't know. 
Now, the issue is that this validates a login, but it does not really log a 
person in. 
Meaning, the session cookie, etc, are not created.

I have used this function with success to authenticate https requests e.g. 
from mobile clients and build REST APIs. 

Luca

On Sunday, August 11, 2013 2:15:47 AM UTC-7, mweissen wrote:
>
> Hi,
>
> I want to build a command line login, eg.
>
> https://my.domain.com/app/contr/mylogin?user=abc&pwd=secret
>
> (Yes, this could be a security risk). At first I have tried to learn more 
> about auth.user_login. The function
>
> def ulogin():
> auth.login_user(1)
>
> returns the following ticket:
>
> Ticket ID
>
> 127.0.0.1.2013-08-11.10-58-17.4854fae8-71bb-4b32-b4bb-2fe044ad3ec3
>  'int' object is not iterable
> Version
>  web2py™ Version 2.5.1-stable+timestamp.2013.06.06.15.39.19  Python Python 
> 2.7.3: D:\Python27\python.exe (prefix: D:\Python27)
> Now I have tried to understand the source code:
>
> def login_user(self, user):
> """
> login the user = db.auth_user(id)
> """
> from gluon.settings import global_settings
> if global_settings.web2py_runtime_gae:
> user = Row(self.db.auth_user._filter_fields(user, id=True))
> delattr(user,'password')
> else:
> user = Row(user)
> for key,value in user.items():
> if callable(value) or key=='password':
> delattr(user,key)
> current.session.auth = Storage(
> user = user,
> last_visit=current.request.now,
> expiration=self.settings.expiration,
> hmac_key=web2py_uuid())
> self.user = user
> self.update_groups()
>
> I think the Row function does some magic.
> Who knows how to use login_user?
>
> Regards Martin
>

-- 

--- 
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: deployment to google app engine did not include my static files

2013-08-12 Thread Luca
Shall I post a working app.yaml (minus confidential details) that works 
with threadsafe=True? 
Let me know if this would help.
Luca

On Sunday, August 4, 2013 12:12:16 PM UTC-7, davedigerati wrote:
>
> as you can see from here: http://sportssquaresonline.appspot.com/
> it did upload most of the static files, specifically 30, but the ones I 
> added, both images and a css file, it did not.
> any idea why???
>
> deployed both through the web2py admin feature and the GAE Launcher
>
>

-- 

--- 
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: Request: Course about Web2py & TDD + pledge for cash

2013-08-12 Thread Luca
I will be teaching a web dev class at UCSC based on web2py, and I may make 
the videos available in YouTube.  
Starting around September 20. 
Email me if you are interested - l...@ucsc.edu

Thanks! -Luca

On Sunday, August 11, 2013 10:29:46 AM UTC-7, Mika Sjöman wrote:
>
> Hi
>
> I am trying to get started with TDD and web2py, but it is really hard 
> since I do not have a CS degree. I have been studying this two courses at 
> Coursera, and especially the former is awesome (I did not like the Intro to 
> Systematic program design so much)
>
> https://class.coursera.org/programming2-001/   # LTHP 
> How to write quality code - awesome!
> https://class.coursera.org/programdesign-001/class/index  #Systematic 
> program design
>
> I just wanted to say that if anyone out there is thinking of writing a 
> book or video course, I would certainly pay for it! Preferably a Udemy 
> course that shows how to do functional testing, unit testing, front end 
> Selenium, integration testing, proper cashing techniques for fast webites 
> etc. Preferably with TDD or some other framework, building lets say 3 to 4 
> small simple projects from scratch. 
>
> I am really sick and tired of writing code that blows up. While web2py 
> gave me an awesome way to easily write code and get going, I have not made 
> much progress writing better quality code with web2py. I think too much 
> time has been spent on learning to program (the language / frameworks), 
> while the problem for me has always been not being able to do proper 
> software engineering. 
>
> So here is a pledge. If any of you good TDD programmers do a small video 
> course on writing web2py software with TDD, Selenium, version control etc, 
> then Ill be happy to chip in 50 USD for such a course. How about a 
> Udemy.com course? Here is the guide to get started: 
> https://www.udemy.com/official-udemy-instructor-course/
> For inspiration about topics I really reccomend looking at that LHTP 
> Writing Quality Code at Coursera. 
>
>
> Anyone else interesting in pledging cash to learn proper software design 
> with Web2py? Maybe someone can make it a kickstarter?
>

-- 

--- 
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: any good open courses with web2py?

2013-04-04 Thread Luca
I am considering teaching one such class in connection with UCSC in the 
Fall of this year. 
Luca

On Thursday, April 4, 2013 6:37:15 AM UTC-7, jjg0 wrote:
>
> Are there any good self paced learning courses on webdev with web2py?  
>
> So far I am enjoying learning how to make websites with web2py.  I don't 
> mind spending a little money on courses or learning material, but I really 
> only do this as a hobby so I'm not interested in shelling out several grand 
> for courses that offer college credits, degrees, certificates, or any of 
> those intensive bootcamps.  Looking at other online courses offered that 
> aren't in web2py I see some really good ideas for projects I would like to 
> be able to build.  One site, for example, had a netflix clone as a final 
> project with ruby on rails, complete with commerce and everything you would 
> need.  Unfortunately the site was very expensive and not in web2py:(
>
> Playing around with php a while back before I found web2py I remember 
> following several teach yourself projects but found them to be incomplete.  
> For example, there were a lot of build a blog tutorials but the end result 
> was a form to enter blog entries and a page that grabbed entries from the 
> db and displayed them.  I didn't like this because the end result was a 
> blog you couldn't actually use, there was no search features, no tagging, 
> no commenting, no user auth, etc.
>
> I can build simple sites, so I'm not looking for an introductory course. 
> For example, the last site I made with web2py was for my friends school 
> with the following:
> -School information, schedules, location, instructors, etc
> -a blog like feature to post upcoming events. I posted links to only 
> future events on the front page. This behaved similar to a blog
> -a blog for the owner to blog about his school or whatever else he 
> wanted.  Had an archive dropdown menu, comments were working at one point 
> but disabled on request of the owner
> -2 forms for people to signup or ask questions. A pdf page can be 
> generated based on the information provided, and a link is emailed to the 
> owner.  I was originally going to just make a pdf and mail that to the 
> owner as an attachment, but I could never get that working
>
> This wasn't too hard to make, but I struggled on a few parts and my code 
> may not exactly be best practice.  It would be nice to find tutorials or 
> open courses I could follow with more challenging projects to get me making 
> more complicated sites and breaking any bad habits I may have picked up.  
> Any Suggestions?
>
> Thanks
>

-- 

--- 
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] Do delete of a record appearing in a list:reference cascade?

2013-04-04 Thread Luca
Suppose I have: 

db.define_table('table_a', 
Field('name'),
)

db.define_table('table_b',
Field('my_a', 'list:reference table_a'),
)

I create a row_a in table a, and I put its id as member of the list my_a in 
row_b of table_b. 

Suppose I then delete row_a.  What happens? 

   1. row_b is unaffected
   2. The reference to row_a in field my_a of row_b is removed
   3. row_b is removed
   4. Other?

Many thanks,  Luca

-- 

--- 
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: browser question

2013-02-20 Thread Luca Zacchetti
Do you mean to start it in a browser different form the default-system one?

Il giorno mercoledì 20 febbraio 2013 16:52:49 UTC+1, Hector Magnanao ha 
scritto:
>
> Is there a way to specify a different browser when I launch web2py ?

-- 

--- 
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: how to select all rows in Google Appengine, to produce a SQLFORM.grid for a whole table?

2013-02-15 Thread Luca
Found: 

q = db.table

seems to work.  Aha! --Luca

On Friday, February 15, 2013 3:03:34 PM UTC-8, Luca wrote:
>
> I need to form a SQLFORM.grid in Google Appengine that will select all 
> rows. 
> Normally, I would use something like: 
>
> q = (db.table.id > 0)
> grid = SQLFORM.grid(q, ...)
>
> But in GAE, there are restrictions on inequality queries, so it seems 
> silly to use an inequality to get all rows. 
>
> Is there a better solution? 
>
> Luca
>

-- 

--- 
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] how to select all rows in Google Appengine, to produce a SQLFORM.grid for a whole table?

2013-02-15 Thread Luca
I need to form a SQLFORM.grid in Google Appengine that will select all 
rows. 
Normally, I would use something like: 

q = (db.table.id > 0)
grid = SQLFORM.grid(q, ...)

But in GAE, there are restrictions on inequality queries, so it seems silly 
to use an inequality to get all rows. 

Is there a better solution? 

Luca

-- 

--- 
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] Form for Polymodel

2013-02-01 Thread Gian Luca Decurtins
Hi all

I'm building an web2py app on GAE which shall be able to manage different 
sensor types:
- integer input
- double input
- boolean input

For each sensor I would like to be able to define a range of good values. 
For example the water sensor is in a good state when the input is false. 
The temperature sensor would be in a good state if the input is between 
18.0 and 20.5.

I did create a Polymodel:
sensor
- sensor integer
- sensor double
- sensor boolean

Does web2py provide an out of the box interface to Polymodels? Something 
like SQLFORM.grid. But the "Add", "Edit" and "View" functionality should 
change the fields if I select an other class. For example I open the sensor 
form, press the "Add"-button, select the class, and enter the values which 
are required for this class.

Or is there an other way to implement something like this?

Best wishes
-Luca.

-- 

--- 
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] Controller: same function with and without arguments

2013-01-30 Thread Gian Luca Decurtins
Hi all

What do you think about the following code example? Is there a more elegant 
way to be able to call a function with and without arguments?
How can I select the fields which shall be returned? I did try it in the 
.select(db.location.id, db.location.name) part, but the JSON output always 
contained all the fields.

Cheers
-Luca.

def read():

if (request.args(0) == None):

default_sort_order = [db.location.country, db.location.city, 
db.location.street_name, db.location.street_number, db.location.building, 
db.location.name]

locations = db().select(orderby = default_sort_order)

return dict(locations = locations)

else:

location = db(db.location.id == request.args(0)).select().first()

return dict(location = location)

-- 

--- 
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: Open generated file from action function

2013-01-29 Thread Luca Zacchetti
Just trying to return an excel file on SQLFORM submission

Il giorno martedì 29 gennaio 2013 22:13:18 UTC+1, Massimo Di Pierro ha 
scritto:
>
> I do not understand what you are trying to do. If the form is accepted you 
> should probably reload, not return different data.
>
> On Tuesday, 29 January 2013 10:00:56 UTC-6, Luca Zacchetti wrote:
>>
>> Hi everybody, I've a problem and need your help.
>> I have a view which contains many things including an SQLFORM.factory 
>> used to set the query for a report generation.
>> The first time I submit the form the report is correctly opened, the 
>> second time the page is just reloaded...how can I fix the problem?
>> Here is my code snippet...
>>
>> def index():   
>> form = SQLFORM.factory(...)
>> if form.accepts(request.vars, session): 
>> #report generation...
>> response.headers['Content-Type']='application/vnd.ms-excel'
>> response.headers['Content-Disposition']='attachment; 
>> filename=%s.xls'%filename
>> response.headers['Content-Title']='%s.xls'%filename 
>> return data #otherwise the file isn't opened   
>> return locals()
>>
>> Many thanks!
>>
>>

-- 

--- 
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] Open generated file from action function

2013-01-29 Thread Luca Zacchetti
Hi everybody, I've a problem and need your help.
I have a view which contains many things including an SQLFORM.factory used 
to set the query for a report generation.
The first time I submit the form the report is correctly opened, the second 
time the page is just reloaded...how can I fix the problem?
Here is my code snippet...

def index():   
form = SQLFORM.factory(...)
if form.accepts(request.vars, session): 
#report generation...
response.headers['Content-Type']='application/vnd.ms-excel'
response.headers['Content-Disposition']='attachment; 
filename=%s.xls'%filename
response.headers['Content-Title']='%s.xls'%filename 
return data #otherwise the file isn't opened   
return locals()

Many thanks!

-- 

--- 
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: session.flash not working?

2012-12-21 Thread Luca
I searched the code base, and I cannot find any place where an assignment 
like: response.flash = session.flash appears. 
Is this broken?  

On Friday, December 21, 2012 1:53:21 PM UTC-8, Luca wrote:
>
> I have this very simple code: 
>
> session.flash = T('The contest is still open to submissions.')
> session.foo = T('pooh')
> logger.debug('contest still open to submissions')
> redirect(URL('default', 'index'))
>
> on the default/index controller, I can see that session.foo is 'pooh', 
> session.flash is None (as it should), BUT request.flash is also None. 
> So no message gets flashed.  This with the most recent development version 
> of web2py (just fetched from github). 
> Is the logic behind session.flash somehow broken? 
>
> Luca
>

-- 





[web2py] session.flash not working?

2012-12-21 Thread Luca
I have this very simple code: 

session.flash = T('The contest is still open to submissions.')
session.foo = T('pooh')
logger.debug('contest still open to submissions')
redirect(URL('default', 'index'))

on the default/index controller, I can see that session.foo is 'pooh', 
session.flash is None (as it should), BUT request.flash is also None. 
So no message gets flashed.  This with the most recent development version 
of web2py (just fetched from github). 
Is the logic behind session.flash somehow broken? 

Luca

-- 





[web2py] Re: Problem with fields option of SQLFORM.grid

2012-12-21 Thread Luca
Ok, I figured it out, I can include db.submission.contest_id among the 
fields, and before calling SQLGRID.form, do
db.submission.contest_id.readable = False

Luca

On Friday, December 21, 2012 12:42:37 PM UTC-8, Luca wrote:
>
> I have a problem using SQLFORM.grid and its fields option. 
> fields= enables me to specify which fields to retrieve from the db, and 
> those fields are then displayed to the user. 
> The problem is, I would like to read from the database also some 
> additional fields, which are NOT displayed to the user, but that can be 
> used in generating links.  For instance, I would like this code to work. 
>  Notice how I am not including db.submission.contest_id in the fields, but 
> I would like to use it in the links (hence, this code is currently broken). 
>
> Is there a way to do this?  Shall I implement in web2py a new optional 
> parameter for SQLFORM.grid called extra_fields? 
> Many thanks! --Luca
>
> grid = SQLFORM.grid(q,
> fields=[db.submission.id, db.submission.date],
> csv=False, details=False, create=False, editable=False,
> user_signature=False,
> args=request.args[1:],
> links=[
> dict(header=T('Contest'), body = lambda r: 
> A(T('Contest'), _href=URL('contests', 'view_contest', 
> args=[r.contest_id]))),
> dict(header=T('Submission'), body = lambda r: 
> A(T('submission'), _href=URL('submission', 
> 'view_own_submission', args=[r.id]))),
> dict(header=T('Feedback'), body = lambda r:
> A(T('feedback'), _href=URL('view_feedback', args=[r.id
> ]))),
> ],
> )
>
>

-- 





[web2py] Problem with fields option of SQLFORM.grid

2012-12-21 Thread Luca
I have a problem using SQLFORM.grid and its fields option. 
fields= enables me to specify which fields to retrieve from the db, and 
those fields are then displayed to the user. 
The problem is, I would like to read from the database also some additional 
fields, which are NOT displayed to the user, but that can be used in 
generating links.  For instance, I would like this code to work.  Notice 
how I am not including db.submission.contest_id in the fields, but I would 
like to use it in the links (hence, this code is currently broken). 

Is there a way to do this?  Shall I implement in web2py a new optional 
parameter for SQLFORM.grid called extra_fields? 
Many thanks! --Luca

grid = SQLFORM.grid(q,
fields=[db.submission.id, db.submission.date],
csv=False, details=False, create=False, editable=False,
user_signature=False,
args=request.args[1:],
links=[
dict(header=T('Contest'), body = lambda r: 
A(T('Contest'), _href=URL('contests', 'view_contest', 
args=[r.contest_id]))),
dict(header=T('Submission'), body = lambda r: 
A(T('submission'), _href=URL('submission', 
'view_own_submission', args=[r.id]))),
dict(header=T('Feedback'), body = lambda r:
A(T('feedback'), _href=URL('view_feedback', args=[r.id]))),
],
)

-- 





[web2py] crud.update returning 404 NOT FOUND ??

2012-12-07 Thread Luca
I have the following simple code, which is meant to let a user do a new 
submission, or update a submission if one exists:

sub = db(db.submission.author == auth.user_id).select().first() 
form = crud.update(db, 
record=sub,
deletable=True,
next=URL('default', 'index'),
)
return dict(form=form)

sub is None, initially, as there is no submission, and so the crud (I am 
hoping) should behave like a create. 
Instead, I get a 404 NOT FOUND.  Is this normal?  What's the proper way of 
doing this? 

It's  a bit bizarre also to get a page that says 404 NOT FOUND, rather than 
having my browser report 404 because it is not finding a page. 
It's like getting a letter in the mail that says, today you got no mail! 
:-) 

Thanks for all the help, 

Luca

-- 





Re: [web2py] Can I have field comments while editing, but not in view?

2012-12-07 Thread Luca
Thanks... what I really don't know is, if you do that, is it a permanent 
change to the db.table.field definition, or is it for the processing of the 
current request only? 
I think my confusion is due to the fact that in other formalisms (e.g. 
Django), these settings are permanent, as not everything is re-loaded at 
each request. 

Luca

On Friday, December 7, 2012 5:46:42 PM UTC-8, rochacbruno wrote:
>
>
> if request.args[0] in ['edit']:
>> db.table.field.comment = 'yadayada'
>>
>

-- 





[web2py] How to define a database "deserialiation" function to decide the editable form of a field?

2012-12-07 Thread Luca
Suppose I want to store some data in the database, defining my own 
translation from user-defined strings to db representation, and vice versa. 
 Obviously this may not work for search, but leave search aside. 

To translate from user input to db representation, I can use the compute= 
attribute of a Field.
But how can I translate from db representation to editable string?  There 
is represent= , but it does something else. 

The context in which I need this is dates. 
I would like that, if a user leaves a date blank, I replace it in the db 
with a certain date (for instance, Year = MINYEAR, or YEAR = MAXYEAR, to 
imply that the date is far in the past or future, so that searches with < > 
will work properly).   But, when the user edits the field, I want to 
restore the blank field, not have them edit a date of Jan 1,  !  That 
would be illogical, since they never entered that date. 

This is a very general problem I imagine.  Is there a way to define such 
translations between stored and editable values in web2py?  Can it be 
added?  Where would one go to add it? 

Luca

-- 





[web2py] Can I have field comments while editing, but not in view?

2012-12-07 Thread Luca
I am using SQLFORM.grid, and if I set:

db.table.field.comment = 'yadayada'

I would like 'yadayada' to appear while editing the field (to help users to 
understand what to put in), 
but not while displaying the field in view mode (because there, I can use 

db.table.field.represent = my_smart_representation

to help users understand whatever I put in the db). 

Is there a way to add an argument to SQLFORM.grid, so that comments are 
only displayed during view?  Does this make sense as a feature request?  (I 
can also implement it, no problems, but is there a  way already to do 
this?). 

Best, Luca

-- 





[web2py] How to customize when the top menu navigation collapses?

2012-12-07 Thread Luca
I would like to use a minimal top bar for my site, where there are items 
from response.menu on the left, and the login information on the right. 
 However, I notice that the menu items are collapsed when there is still a 
lot of space on the top bar -- I need to use a VERY wide browser window in 
order to have the menu items ('Home' in the attached screenshots) appear in 
the top menu bar.  
Is it possible to fine-tune when the menu items in response.menu are 
collapsed, and toggled on/off via the button, vs. displayed on the top bar? 
 Ideally, I would like collapsing only if the items clash with the login 
information. 
I hope this makes sense, but the screenshots really make it clear  I 
would like 'Home' to appear on the top even when the browser is in the 
narrower of the two screenshots. 

Many thanks! 
Luca

-- 



<><>

[web2py] Re: class nav-collapse in layout.html

2012-12-07 Thread Luca
I have the problem that the menus are collapsed even when there is ample 
space on the navbar for the items. 
Removing nav-collapse and replacing with nav solves this, but the menu 
button still appears before it is actually needed. 
Does anyone know how to fine tune the behavior of menu collapse? 
Luca

On Thursday, August 16, 2012 3:05:09 PM UTC-7, mweissen wrote:
>
> I have a program with a menu and I tried Firefox and Google Chrome:
> Chrom shows the menu, Firefox not.
>
> Line 76 in layout.html is:
> 
>
> I could not find a definition for the class "nav-collapse".
>
> Next step: I removed this class definition
>
>
>   
>   {{is_mobile=request.user_agent().is_mobile}}
>   {{if response.menu:}}
>   {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 
> 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}}
>   {{pass}}
> 
>
> and the menu is visible again in both browsers.
> What is the reason?
>
> Regards, Martin
>
>
> -- 
> Mit freundlichen Grüßen / With kind regards 
> Martin Weissenböck
> Gregor-Mendel-Str. 37, 1190 Wien
> Austria / European Union
> Tel  +43 1 31400 00
> Fax  +43 1 31400 70
>

-- 





[web2py] How to make an admin session longer?

2012-11-30 Thread Luca
I am developing an app, and I find it annoying that I get so many 
"communication error" when I try to save after working on the code for some 
length of time.
Is there a way for me to increase the timeout of the admin session, so that 
I don't get so many disconnections when I edit? 
Security is not a concern, since I am using admin mode only from localhost. 
Many thanks!

Luca

-- 





[web2py] Re: SQLFORM.grid and classes on GAE

2012-11-30 Thread Gian Luca Decurtins
HI cfh

You're right. As far as I can see in the datastore viewer there is only one 
table. There is also a class value available.

I did try a few more things (resetting local datastore and removing the 
entries in index.yaml) but I'm not able to access all three tables using 
the following controller:

@auth.requires_signature()

def form():

table = request.args(0)

if not table in db.tables(): redirect(URL('error'))

db[table].id.readable = False

form = SQLFORM.grid(db[table],args=request.args[:1], 
user_signature=True)

return dict(form=form)

When I do call 
"http://localhost:8080/init/location/form/location_outdoor?_signature=xxx' 
I receive:

AttributeError: 'location' object has no attribute 'country'


When I call 
"http://localhost:8080/init/location/form/location_indoor?_signature=xxx' I 
receive:

AttributeError: 'location_outdoor' object has no attribute 
'location_outdoor'


Right after resetting the datastore I'm able to access 'location, 
'location_outdoor' and 'location_indoor'. Once I create an indoor or 
outdoor location I'm not able to access the other form anymore. The 
'location' form is still available.


I'm trying to store all location information (outdoor / indoor) in one 
polymodel. I do want to take advantage of having to have only one reference 
between devices and locations.


Any suggestions?


Greetings

-Luca.


Am Donnerstag, 29. November 2012 19:27:03 UTC+1 schrieb howesc:
>
> i have not used polymodels so i can't answer the last question.but 
> about that last one, when you access the GAE datastore viewer (as provided 
> by GAE), what is the name of the table/model that is stored there?  does it 
> store location_indoor  and location_outdoor, or just location with optional 
> fields?  (i'd personally expect the former, but your experience sounds like 
> the latter).
>
> for your other questions see the example under this heading 
> http://web2py.com/books/default/chapter/29/07?search=grid#SQLFORM.grid-and-SQLFORM.smartgrida
>  few paragraphs in it shows a controller that can handle any table.
>
> cfh
>
> On Thursday, November 29, 2012 6:41:40 AM UTC-8, Gian Luca Decurtins wrote:
>>
>> Hi all
>>
>> Given the following model (polymodel location -> location_outdoor & 
>> location_indoor) on GAE:
>>
>> define_table('location',
>> Field('name', 'string'),
>> Field('active', 'boolean'),
>> polymodel = True)
>>
>> define_table('location_outdoor',
>> db.location,
>> Field('country', 'string'),
>> Field('city', 'string'),
>> Field('postcode', 'string'),
>> Field('street', 'string'),
>> Field('building', 'string'),
>> polymodel = db.location)
>>
>> define_table('location_indoor',
>> db.location
>> Field('location_outdoor', db.location_outdoor),
>> Field('floor', 'string'),
>> Field('room', 'string'),
>> polymodel = db.location)
>>
>> - Is there a way to create a generic controller (using SQLFORM.grid) 
>> which is able to create outdoor or indoor locations (display either 
>> location_outdoor or location_indoor fields)?
>> I'm thinking of a select field where I can select the class. Depending on 
>> the class it will show the available fields.
>> I should be able to modify the SQLFORM.grid to get view and edit 
>> operations to use the correct class. But what about the create operation?
>>
>> - How can I add an extra field to the SQLFORM.grid view form which 
>> displays the location? I would like to add a field which does contain a 
>> generated QR-code.
>>
>> - Why are the indexes in index.yaml always called "location" and not 
>> "location_outdoor" and "location_indoor"? I'm often receiving the error 
>> message that location_indoor does not contain 'city', which is true.
>>
>> Cheers
>> -Luca.
>>
>

-- 





[web2py] SQLFORM.grid and classes on GAE

2012-11-29 Thread Gian Luca Decurtins
Hi all

Given the following model (polymodel location -> location_outdoor & 
location_indoor) on GAE:

define_table('location',
Field('name', 'string'),
Field('active', 'boolean'),
polymodel = True)

define_table('location_outdoor',
db.location,
Field('country', 'string'),
Field('city', 'string'),
Field('postcode', 'string'),
Field('street', 'string'),
Field('building', 'string'),
polymodel = db.location)

define_table('location_indoor',
db.location
Field('location_outdoor', db.location_outdoor),
Field('floor', 'string'),
Field('room', 'string'),
polymodel = db.location)

- Is there a way to create a generic controller (using SQLFORM.grid) which 
is able to create outdoor or indoor locations (display either 
location_outdoor or location_indoor fields)?
I'm thinking of a select field where I can select the class. Depending on 
the class it will show the available fields.
I should be able to modify the SQLFORM.grid to get view and edit operations 
to use the correct class. But what about the create operation?

- How can I add an extra field to the SQLFORM.grid view form which displays 
the location? I would like to add a field which does contain a generated 
QR-code.

- Why are the indexes in index.yaml always called "location" and not 
"location_outdoor" and "location_indoor"? I'm often receiving the error 
message that location_indoor does not contain 'city', which is true.

Cheers
-Luca.

-- 





[web2py] Row level access on GAE datastore

2012-11-25 Thread Gian Luca Decurtins
Hi all

How do I enable row level access features on GAE datastore?
In the documentation is written that the accessible_query does not work 
because of the usage of JOIN. Is there an other way of using it?

I think it could work using google:sql instead of google:datastore, but I'm 
trying to avoid using google:sql.
Also I do think it does not work using decorators in controllers. They seem 
to just limit access to functions, not the queries.

I do want to create a device table where users can only view or edit their 
own entries. How would you implement this on GAE?

Greetings
-Luca.

-- 





[web2py] Trouble with JQuery UI - use 1.8.24 not what ships

2012-11-13 Thread Luca
I had trouble using the native autocomplete provided in JQuery UI: the 
autocomplete list would not attach to the  element where the entry 
occurred, but rather, it would attach to the "window" in general.  Closer 
inspection revealed errors in the execution of JQuery UI. 

I solved the errors by including version 1.8.24 of JQuery UI, not the 
1.8.18 version that is the default in layout.html. 
I am mentioning this in case it can save other people's time. 

Actual lines I used:

   http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/base/jquery-ui.css";
 
type="text/css" media="all" />
   http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js"</a>; 
type="text/javascript">

Luca

-- 





[web2py] Re: What can cause "unable to install application"?

2012-11-09 Thread Luca
Massimo, 

I teach at UCSC; here is the class web 
page: 
https://sites.google.com/a/ucsc.edu/luca/classes/cmps-183-hypermedia-and-the-web/cmps-183-fall-2012
 
Thank you for the help; I will do this next time a student package does not 
load properly! 
Luca

On Friday, November 9, 2012 8:18:21 AM UTC-8, Massimo Di Pierro wrote:
>
> Hello Luca,
>
> where do you teach?
>
> Look into gluon/admin.py app_install. There is a try...except. Try replace
>
> except Exception:
> if did_mkdir:
> rmtree(path)
> return False
>
> with
>
> except Exception:
> import traceback
> print traceback.format_exc()
> if did_mkdir:
> rmtree(path)
> return False   
> 
>
> Also if you open a ticket about this, I will make sure better errors are 
> reported via admin.
> I have apps that allows students to upload projects w2p and bulk install 
> them, bulk register and test them. Need polishing.
> Remind me in a couple of weeks and I will be happy to share them.
>
> Massimo
>
> On Friday, 9 November 2012 00:08:32 UTC-6, Luca wrote:
>>
>> I am using web2py to teach a class on web development, and sometimes the 
>> students submit .w2p packages as assignments that cannot be loaded.  When I 
>> or the TAs try to load them, we get the "unable to install application" 
>> message. 
>>
>> What can cause this message? 
>>
>> The packages open without problem when I tar xfvz them, so it's not clear 
>> to me what the problem is. 
>>
>> Many thanks!
>>
>

-- 





[web2py] What can cause "unable to install application"?

2012-11-08 Thread Luca
I am using web2py to teach a class on web development, and sometimes the 
students submit .w2p packages as assignments that cannot be loaded.  When I 
or the TAs try to load them, we get the "unable to install application" 
message. 

What can cause this message? 

The packages open without problem when I tar xfvz them, so it's not clear 
to me what the problem is. 

Many thanks!

-- 





[web2py] Simple logging not working?

2012-11-08 Thread Luca
I tried this simple way to log (to help debugging, not really for 
production logging):

import logging
logging.basicConfig(filename="/tmp/web2py.log", level=logging.INFO)
logging.info("this is not output")

The above does not work.  I know that there is a solution that works 
at http://www.web2pyslices.com/slice/show/1416/logging , but my question 
is, why does the simpler method not work? 

I also tried to put the first two lines (the  import, and the 
logging.basicConfig) in db.py, but it does not seem to work. 
Any insight would be appreciated.

-- 





[web2py] Re: Problem updating list fields

2012-09-22 Thread Luca
Why not?  I thought (as in functional programming) that the update 
statement was specifying an expression to be called on every resulting row, 
and so I wrote an expression that defines a new list given an old list -- 
just as you might define a new integer value on the basis of an old integer 
value. 

Luca

On Friday, September 21, 2012 7:50:09 PM UTC-7, Massimo Di Pierro wrote:
>
> There is no way to append an element to every list.
>
> On Friday, 21 September 2012 19:45:12 UTC-5, Luca wrote:
>>
>> Suppose you have:
>>
>> db.define_table('membership',
>> 'user_id': db.auth_user,
>> 'things': 'list: reference thing'
>> )
>> db.define_table('thing', ...)
>>
>> The following does not work:
>>
>> db(db.membership.user_id = 
>> 2).update(things=list_add(db.membership.things, 3))
>>
>> where
>>
>> def list_add(l, e):
>> if e in l:
>> return l
>> else:
>> return l + [e]
>>
>> The problem seems to be that the db.membership.things field that is 
>> passed to list_add is, somehow, NOT a list. 
>>
>>

-- 





[web2py] Problem updating list fields

2012-09-21 Thread Luca
Suppose you have:

db.define_table('membership',
'user_id': db.auth_user,
'things': 'list: reference thing'
)
db.define_table('thing', ...)

The following does not work:

db(db.membership.user_id = 2).update(things=list_add(db.membership.things, 
3))

where

def list_add(l, e):
if e in l:
return l
else:
return l + [e]

The problem seems to be that the db.membership.things field that is passed 
to list_add is, somehow, NOT a list. 

-- 





[web2py] Bug with list:string in SQLFORM.factory?

2012-09-21 Thread Luca
I am using web2py 2.0.8 on a Mac.  I defined the following controller:

@auth.requires_login()
def edit_members():
current_emails = ['em...@some.com']
form = SQLFORM.factory(Field('members', 'list:string',
default=current_emails,
))
if form.process().accepted:

else:
session.flash = T('Some user emails were invalid.')
return dict(form=form)

I cannot get the form to validate.  Moreover, quite often, web2py goes into 
a mode in which it uses 100% CPU, becomes unresponsive, and must be killed 
(force quit). 
So, there seems to be some bug in the validation of list:string fields in 
SQLFORM.factory produced forms. 

Luca

-- 





[web2py] Re: Problem with setting a default value for list:string fields in forms

2012-09-21 Thread Luca
In fact, this seems to be a bug not so much with setting default values, 
but with form validation. 
I am doing: 

if form.process().accepted:

and somehow, in this validation process, if the string fields are ['a', 
'b'] (the string 'a' filled in the first entry line, and 'b' in the second 
line), then after validation, this is turned into ["['a', 'b']", "['a', 
'b']"], so that each of the two fields consists now of the string "['a', 
'b']".  The bug seems to be in the validation.  Am I doing something wrong, 
or is this a web2py bug? 

Luca

On Friday, September 21, 2012 3:20:28 PM UTC-7, Luca wrote:
>
> I have the following code snippet: 
>
> form = SQLFORM.factory(Field('members', 'list:string',
> requires=IS_LIST_OF(IS_IN_DB(db, 'auth_user.email', '%(email)s')),
> ))
> form.vars.members = current_emails
>
> This does not work.  if current_email is ['a...@b.com'] for instance, then 
> the field gets populated with the string '[a...@b.com]' (including the 
> square brackets!). 
> I tried also: 
>
> form = SQLFORM.factory(Field('members', 'list:string',
> requires=IS_LIST_OF(IS_IN_DB(db, 'auth_user.email', '%(email)s')),
> default=current_emails
> ))
>
> but this causes an even weirder problem.  If the user enters a...@b.com, and 
> c...@d.com as the two emails, assuming they do not belong to any user, then 
> the form is redisplayed with a notice that there were errors, but on EACH 
> of the two entries of the form, the single email addresses are BOTH 
> replaced with the string "['a...@b.com', 'c...@d.com']" . 
>
> I guess this is a bug? 
> How can I specify the initial value for a list:string field in a 
> SQLFORM.factory form? 
> Many thanks!
>
> Luca
>

-- 





[web2py] Problem with setting a default value for list:string fields in forms

2012-09-21 Thread Luca
I have the following code snippet: 

form = SQLFORM.factory(Field('members', 'list:string',
requires=IS_LIST_OF(IS_IN_DB(db, 'auth_user.email', '%(email)s')),
))
form.vars.members = current_emails

This does not work.  if current_email is ['a...@b.com'] for instance, then the 
field gets populated with the string '[a...@b.com]' (including the square 
brackets!). 
I tried also: 

form = SQLFORM.factory(Field('members', 'list:string',
requires=IS_LIST_OF(IS_IN_DB(db, 'auth_user.email', '%(email)s')),
default=current_emails
))

but this causes an even weirder problem.  If the user enters a...@b.com, and 
c...@d.com as the two emails, assuming they do not belong to any user, then 
the form is redisplayed with a notice that there were errors, but on EACH 
of the two entries of the form, the single email addresses are BOTH 
replaced with the string "['a...@b.com', 'c...@d.com']" . 

I guess this is a bug? 
How can I specify the initial value for a list:string field in a 
SQLFORM.factory form? 
Many thanks!

Luca

-- 





[web2py] Store DB connection information in private/ folder

2012-08-10 Thread Gian Luca Decurtins
Hi all

How do I store the DB connection information (db = DAL(...)) in the 
private/ folder?

I would like to sync the application using Mercurial. The local DB 
information should not be shared.
The .hgignore file already includes "private/*".

Cheers
-Luca.

-- 





[web2py] Error in web2py book for auth.login_bare

2012-05-22 Thread Luca
In http://web2py.com/books/default/chapter/29/9 it is stated that 
auth.login_bare returns None if the username/password pair is invalid. 
auth.login_bare actually returns False, not None. 
I guess most people do:

user = auth.login_bare(u, p)
if not user:
raise HTTP(403, "Authorization Failed.")

but if one does (as I did), 

if user is None:

then the difference is noticeable.  I am posting this so that the error is 
documented. 
Luca


[web2py] How to create a user account programmatically?

2012-05-21 Thread Luca
To validate a user-password pair, I can use auth.login_bare. 
Two questions: 

   1. Auth.login_bare does not cause the user to be logged in: for 
   instance, auth.user_id is not set afterwards.  Is there a way to also log 
   in a user, not only validate the username/password pair? 
   2. Suppose I want to programmatically create a user account (e.g., to 
   build a back end for a mobile app, that only has a json interface).  Is 
   there an auth.create_user(first_name, last_name, email, password) method? 
   
Thanks! 

Luca


[web2py] SQLFORM.grid search using signature

2012-03-19 Thread Gian Luca Decurtins
Hi all

I can't perform search operations on SQLFORM.grid forms. If I remove the 
"@auth.requires_signature()" part, it does work.

In the webserver-logfile I noticed that the edit page is signed, while the 
search page isn't.
EDIT: 
/init/location/form/edit/location/4?_signature=368187847e306b826b2c5a1f8a4780c236aafb8c
SEARCH: /init/location/form?keywords=test

Given the following code in controller location.py:

@auth.requires_signature()
def form():
db.location.id.readable=False 
query=((db.location.id > 0 ))
default_sort_order=[db.location.country]
form = SQLFORM.grid(query=query, orderby=default_sort_orderr,
create=True, deletable=True, editable=True, 
user_signature=True)
return dict(form=form)


What do I have to do to get it working?

Regards
-Gian.


[web2py] Re: CRUD onaccept question

2012-03-09 Thread Gian Luca Decurtins
Thank you Alan!


> onaccept=lambda form: locate(request.args(0)) 


It now works as expected!
-Luca. 


[web2py] CRUD onaccept question

2012-03-09 Thread Gian Luca Decurtins
Hi all

Once again a question related to CRUD: Why is onaccept executed before 
pressing the "Submit" button?
I've written a function "update()" which calls crud.update. After 
submitting new values I would like to look up the location's latitude and 
longitude.
At the moment I'm facing the problem that the function 
"locate(request.args(0))" is called before displaying the location details.
What do I have to change to lookup latitude and longitude after update? Is 
there a way to lookup the coordinates asynchronously?

-Luca.


@auth.requires_signature()
def update():
form = 
crud.update(db.location,request.args(0),next=URL('location','select', 
user_signature=True),onaccept=locate(request.args(0)))
return dict(form=form)

@auth.requires_signature()
def locate(locationId):
from gluon.tools import geocode
location = db.location(db.location.id==locationId)
(lat, long) = geocode("%s %s %s" % (location.country, location.city, 
location.street))
location.update_record(latitude = lat,longitude = long)

@auth.requires_signature()
def select():
db.location.name.represent = lambda name, row: \
   A(name,_href=URL('location','update', args=(row.id), 
user_signature=True))
form = crud.select(table=db.location)
return dict(form=form)


[web2py] Re: CRUD .represent question #2

2012-03-08 Thread Gian Luca Decurtins

>
> That's not how it works. When the table is defined, if you have 
> Field('location', db.location, ...) with no explicit "represent=...", then 
> it will automatically set the "represent" attribute for you based on the 
> _format attribute of the db.location table. However, if you set an explicit 
> "represent" attribute, you won't get the automatically generated version 
> based on _format. In that case, you'd have to do it manually:
>
> db.object.location.represent = lambda location, row: \
> A(db.location._format % db.location(location),
>   _href=URL('location', 'update', args=(location.id), 
> user_signature=True))
>

Thank you very much! Your lines work as expected!
-Luca. 


[web2py] Re: CRUD .represent question #2

2012-03-08 Thread Gian Luca Decurtins

>
> db.object.location.represent = lambda location, row: \
>>A(location,_href=URL('location', 'update', args=(location.id), 
>> user_signature=True))
>>
>
> In the above line, you have specified your own "represent" attribute for 
> the "location" field, so it will not use the "format" attribute of the 
> "location" table to represent the field. The "format" attribute of the 
> referenced table is only used if the field doesn't have its own explicit 
> "represent" attribute.
>
>
I've removed the two lines, but the behavior is still the same. So there 
must be an other error in my code?
My idea is that the format does specify the string for db.object.location 
and the db.object.location.represent should modify the string to be a link. 
Is this not possible at all?

-Luca.


[web2py] CRUD .represent question #2

2012-03-08 Thread Gian Luca Decurtins
Hi all

A crud.select on the object-table does only display the ID of the 
corresponding location, and not as expected ( '%(id)s: %(country)s, 
%(city)s, %(street)s, %(name)s' ).
What is wrong here? Do I have to restart the webserver if I change the 
format part of define_table?

Cheers
-Luca.

db.define_table('object',
   Field('name'),
   Field('description', 'text'),
   Field('location', db.location),
   format = '%(name)s',
   singular = 'Object',
   plural = 'Objects')

db.define_table('location',
   Field('name', 'string', required=True, notnull=True),
   Field('street', length=400),
   Field('city', length=40),
   Field('country', length=40),
   format = '%(id)s: %(country)s, %(city)s, %(street)s, %(name)s',
   singular = 'Location',
   plural = 'Locations')

def select():
db.object.location.represent = lambda location, row: \
   A(location,_href=URL('location', 'update', args=(location.id), 
user_signature=True))
db.object.name.represent = lambda name, row: \
   A(name,_href=URL('object', 'update', args=(row.id), 
user_signature=True))
form = crud.select(table=db.object)
return dict(form=form)


[web2py] Re: CRUD .represent question

2012-03-07 Thread Gian Luca Decurtins
Hi

Yes you're right!
But I had to remove the
db.location.id.readable = False
line. Else it doesn't work.

Thank you for helping!
-Luca.

Am Mittwoch, 7. März 2012 12:18:41 UTC+1 schrieb Alan Etkin:
>
> row.id should contain the record id, shouldn't it? 
>
> db.location.name.represent = lambda name, row: \ 
>A(name, _href=URL('update', args=row.id, user_signature=True)))



[web2py] Re: CRUD .represent question

2012-03-07 Thread Gian Luca Decurtins
Hi

This is exactly the example from which I started. I've removed the 
request.args(0) part, because I do not need the generic controller as I 
already know which table I want to display.
I want to change the representation of db.location.name: Display 
db.location.name, but use db.location.id for the underlying link.


Am Mittwoch, 7. März 2012 11:44:09 UTC+1 schrieb Alan Etkin:
>
> Look at this example (at the book's crud - methods): 
>
> A('edit:',id,_href=URL(args=(request.args(0),id))) 
>
> I think you need to pass a sequence to args (, ) for 
> the required behavior. Not sure really, as I didn't use the example.
>


[web2py] CRUD .represent question

2012-03-07 Thread Gian Luca Decurtins
Hi all

I would like to use CRUD to display a list of locations. If I press on the 
location.name it should call the function update() passing location.id as 
parameter.
I've taken the CRUD manage() example from the web2py book [1] and modified 
it to:

@auth.requires_signature()
def select():
db.location.id.readable = False
db.location.name.represent = lambda name, row: \
   A(name,_href=URL('update',args=(name),user_signature=True))
form = crud.select(table=db.location)
return dict(form=form)

Using the code above it will call update(), but passes the location.name as 
parameter.
I've already tried replacing args=(name) with args=(db.location.id) or 
args=(id), without success.

How is the recommended way to .represent the name-Field using the id-Field 
for the link?

Regards
-Luca.

[1] http://web2py.com/book/default/chapter/07#Methods


Re: [web2py] web2py CRUD example

2012-01-27 Thread Gian Luca Decurtins
Thank you!

I had to edit models/db.py:
# response.generic_patterns = ['*'] if request.is_local else []
response.generic_patterns = ['*']

Regards
-Gian.

BTW: In the original post I've replaced the FQDN with localhost. If the 
application did run on localhost this modification should not be necessary.


[web2py] web2py CRUD example

2012-01-27 Thread Gian Luca Decurtins
Hi all

I'm trying to use the CRUD-feature of web2py (1.99.4). At the moment I'm 
stuck at "invalid view (default/data.html)" while accessing 
https://localhost/init/default/data/tables.
So far I've created a simple application "init" and changed the following:

In controllers/default.py I've disabled required_signature (I did not want 
to play around with permissions at this time):
@auth.requires_login()
# @auth.requires_signature()
def data(): return dict(form=crud())

In views/default.html I've added a link beneath the message:
{{=A('table',_href=URL('data/tables',user_signature=True))}}

If I follow this link (after authenticating) I just receive the error 
message:
invalid view (default/data.html)
I did expect something like a list of tables.

Out of the box there seems to be no default/data.html view.
Do I have to write my own data.html view to test the CRUD functionality? Or 
did I do something wrong in the setup?

Regards
-Gian.


[web2py] How to define the initial value of SQLFORM fields?

2011-10-04 Thread Luca
I need to have a form generated via SQLFORM where the initial values of the 
fields are pre-filled with dynamically generated content. 
What I am trying is (suppose I have a table mytable with title and content 
as fields): 

form = SQLFORM(db.mytable)

form.vars.title = "my title"

form.vars.content = "my content"

if form.accepts(request.post_vars, session):



return dict(form=form)


Yet, if I do this, I get an error that says: 

(No fields to update)

So, how can one define dynamically the values that appear initially in a 
SQLFORM? 
I know that I can define defaults in the models definition, but I want to do 
it dynamically. 

What is the way to do it?  And why do I get the above error? 

Many thanks, 

Luca
 

 

 

 

 


[web2py] Re: How to create a many-to-one (foreign key) relation to a table not yet defined?

2011-09-11 Thread Luca
Oh, I think I see; I should do the first as 

Field('live_revision', 'reference revision')



[web2py] How to create a many-to-one (foreign key) relation to a table not yet defined?

2011-09-11 Thread Luca
I have two tables, let's call them pages and revisions.  Every page has many 
revisions, so every revision contains the page as a foreign key.  The page 
has also one special revision which is the "live" one.  I am doing (cutting 
out the unnecessary code):

db.define_table('page',
Field('live_revision', db.revision),
)

db.define_table('revision',
Field('page', db.page),
)

Now, the first reference to db.revision before the table is created raises 
an error.  In Django, this is solved by quoting the relation name, as in 
'db.revision'. 
Is there a way to solve this in web2py?   
I could of course create a 

Field('live_revision_id', 'integer')

but I see two problems with it: first, I lose the automatic way of doing 
e.g. page.live_revision.author to refer to the revision author, and second, 
I don't think that there is an universal guarantee that auto-generated row 
ids are integers (are they integers also in GAE?). 

This must be an issue that comes up often; what's the solution? 


[web2py] Re: How do I install a plugin??

2011-09-10 Thread Luca
Ah, ok, I figured it out. 

What I expected to be called "install" is called "upload". 
It's kind of funny to have to "upload" something I have just "downloaded", 
but whatever :-)


[web2py] How do I install a plugin??

2011-09-10 Thread Luca
Suppose I downloaded a plugin.  Now I 
have: web2py.plugin.layout_EfflorescenceBlue.w2p
Great; how do I install it?  The book says to use the edit page in admin, 
but I see no such option in the edit page in admin to install a plugin file. 
 There is a link to download plugins (which I have done, now what?), and one 
to upload plugins, but no link to install them. 

What am I to do with my plugin file? 

Thanks! - Luca


[web2py] Re: Where to find in-depth documentation?

2011-09-09 Thread Luca
Thanks, I had missed the short section on Custom-forms...  
I think in general I am both happy and puzzled by how much web2py does for 
me; it's great it does all that, but sometimes I find myself swimming when I 
need a bit more control.  In Django I had the sensation I could more easily 
get to the bottom of things.  It's simple things, like, what if I have to 
insert a couple of records in two database tables, due to the same form 
submission?  All the auto-mechanisms deal with the simple cases, but in 
Django it was a bit easier to figure out how to access e.g. the 'cleaned' 
(validated, reformatted) fields of an accepted form. 

Oh well, everything has a learning curve I guess, and I am having fun! 

Luca


Re: [web2py] Why multiple controllers, models, and what to do with them?

2011-09-08 Thread Luca
Thank you, this is very helpful indeed. 
Luca


[web2py] Re: Why multiple controllers, models, and what to do with them?

2011-09-08 Thread Luca
I understand, but this is very un-python like and weird... you mean that if 
I have 

a = 1

in a file, and then load another file, then a is still 1 also in the other 
file?  This is incredibly weird to me -- normally, files have to import each 
other to share variables in this way. 

Ok... now I just wonder what the precise boundaries of this happy sharing 
are.  Thanks!!

Luca


[web2py] Where to find in-depth documentation?

2011-09-08 Thread Luca
I am new to web2py, as I mentioned in another post, and I am wondering where 
to find in-depth documentation. 
Let me give you an example.  I wanted to do a form that does not correspond 
to a db table, and that has several input fields.  I also wanted to render 
it in a table. 

In the English web2py book, all the examples are with forms which (a) either 
have only one input field, or (b) are derived more or less directly from db 
tables.  I could not find clear documentation anywhere on how to cook up my 
own funny form.  In the end, I understood, or so I think, and I wrote 
something like

form = FORM(TABLE(
TR(TD('City'), TH(INPUT(_name='city', requires=IS_NOT_EMPTY(,
TR(TD('County'), TH(INPUT(_name='county'))),
INPUT(_value='Add', _type='submit', _action=URL('add'

I have no idea whether this is the best way -- I would have preferred to 
leave the HTML tags in the view, rather than in the controller, but then I 
could find no explanation on how to access the components of a form in a 
view. 

Now, the problem is not so much in this form.  The problem is, where is 
documentation that is more in-depth than the overview given in the book?  I 
ran into this problem not only with forms, but with database fields (e.g., 
default=now as cited in the book does not work for datetime fields), with 
the role of controllers, with the way in which models are loaded... 

When _you_ need this information, where do you find it?  What's the secret 
source of knowledge I am missing? :-) 

Luca


[web2py] Why multiple controllers, models, and what to do with them?

2011-09-08 Thread Luca
I am new to web2py (I've been using Django), and I am confused about a 
couple of things. 

First, the presence of multiple controllers. 
I am trying to build a main app, called (say) www.example.com. 
So I would like to have something like www.example.com/index.html
But if I use the default.py controller, the URL that is automatically mapped 
is default/index.html, not index.html directly.  How do people typically 
organize their URL schema? 

Second, in the default setup, I see db.py and menu.py.   In db.py it is 
noted that I should really add my table declarations to another model file.  
But, all the logic to decide if web2py is running on appengine or not, etc, 
is all in db.py; if I write my table declarations in another file, do I have 
to cut and paste that logic?  Or how is this supposed to work?  All the 
example in the tutorial just edit db.py. 

Many thanks! --Luca



[web2py] plugin sortable, connect lists

2010-08-02 Thread Giuseppe Luca Scrofani
I've used the sortable plugin  (
http://www.web2py.com/plugins/default/sortable ) in some projects and
I think it is very useful to arrange list of items in database. What I
miss is the "connect list" functionality (
http://jqueryui.com/demos/sortable/#connect-lists ) of jQuery UI. What
I think can be a useful addition is the ability to have two list (or
more...) representing two (or more!) db tables and, as per example in
the second link, transfer an object from listA to listB and make the
corresponding changes in the db.

Model I think would be like this:

db.define_table('listA',
   Field('sortable','integer',default=0,writable=False,readable=False),
   Field('name'),
   Filed('color'))

db.define_table('listB',
   Field('sortable','integer',default=0,writable=False,readable=False),
   Field('name'),
   Filed('color'))

But my "skill" stop here :D If someone can take the time to elaborate
on this I would be grateful :) Maybe it is possibile to modify a
little the original plugin... I dont know.

It is not urgent, but is time to get this new toy to play around! :D


[web2py] plugin sortable, connect lists

2010-07-25 Thread Giuseppe Luca Scrofani
I've used the sortable plugin  (
http://www.web2py.com/plugins/default/sortable ) in some projects and
I think it is very useful to arrange list of items in database. What I
miss is the "connect list" functionality (
http://jqueryui.com/demos/sortable/#connect-lists ) of jQuery UI. What
I think can be a useful addition is the ability to have two list (or
more...) representing two (or more!) db tables and, as per example in
the second link, transfer an object from listA to listB and make the
corresponding changes in the db.

Model I think would be like this:

db.define_table('listA',
   Field('sortable','integer',default=0,writable=False,readable=False),
   Field('name'),
   Filed('color'))

db.define_table('listB',
   Field('sortable','integer',default=0,writable=False,readable=False),
   Field('name'),
   Filed('color'))

But my "skill" stop here :D If someone can take the time to elaborate
on this I would be grateful :) Maybe it is possibile to modify a
little the original plugin... I dont know.

It is not urgent, but is time to get this new toy to play around! :D


[web2py] plugin sortable, connect lists

2010-07-25 Thread Giuseppe Luca Scrofani
I've used the sortable plugin  (
http://www.web2py.com/plugins/default/sortable ) in some projects and
I think it is very useful to arrange list of items in database. What I
miss is the "connect list" functionality (
http://jqueryui.com/demos/sortable/#connect-lists ) of jQuery UI. What
I think can be a useful addition is the ability to have two list (or
more...) representing two (or more!) db tables and, as per example in
the second link, transfer an object from listA to listB and make the
corresponding changes in the db.

Model I think would be like this:

db.define_table('listA',
Field('sortable','integer',default=0,writable=False,readable=False),
Field('name'),
Filed('color'))

db.define_table('listB',
Field('sortable','integer',default=0,writable=False,readable=False),
Field('name'),
Filed('color'))

But my "skill" stop here :D If someone can take the time to elaborate
on this I would be grateful :) Maybe it is possibile to modify a
little the original plugin... I dont know.

It is not urgent, but is time to get this new toy to play around! :D


  1   2   >