[web2py] Putting time in a string

2015-11-04 Thread Garry Smith
H i

I am trying to put the current time in a email message using the following:-


Enter code here...def index(): 
import datetime

ip = str(request.client)
t = str(datetime.datetime.today())


form = SQLFORM.factory(
Field('name', requires=IS_NOT_EMPTY()),
Field('Date_of_Birth',requires=IS_DATE(format=T('%d/%m/%Y'))),
#Field('Form', requires =IS_NOT_EMPTY()),
#Field('subject', requires=IS_NOT_EMPTY()),
Field('message', requires=IS_NOT_EMPTY(), type='text')
)
if form.process().accepted:
session.name = form.vars.name
session.dob = form.vars.Date_of_Birth
session.message = form.vars.message
session.time = t

x = mail.send(to=['hua-c...@humberstonacademy.co.uk'],
subject='SOS HELP',
message= "Message from.\nName: "+ session.name +" \nTime: " + 
time + "\n DoB: " +session.dob +  "\nMessage : "+session.message+ ".\n "
)

if x == True:
response.flash = 'email sent sucessfully.'
else:
response.flash = 'fail to send email sorry!'

#response.flash = 'form accepted.'
elif form.errors:
response.flash='form has errors.'

return dict(form=form)


I am getting the following error :-
cannot concatenate 'str' and 'datetime.date' objects

I get the the same message if I try and put the ip address in the email 
message.

I have converted both time and ip to a string, so not sure why I am getting 
the error.

Thanks


G Smith


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


Re: [web2py] How to get my pdf-file to display from webserver

2015-11-04 Thread Karl Florian
Thanks!

The first part is working!!! The filename is as it is supposed to be!
This is my code at the Moment, maybe some can use it:

  ltxfile = str(os.path.join(request.folder, 'tex', 'languages.tex'))

  pdffile = str(os.path.join(request.folder, 'tex', 'languages.pdf'))

  #

  #Create and Close the TEX-File ...

  #

  os.system('pdflatex '+ltxfile)  #create the PDF file

  if os.path.isfile(pdffile):#remove old file from the tex directory

  os.remove(pdffile)

  os.rename('languages.pdf', pdffile) #move PDF file to the tex 
directory

  import cStringIO

  pdfdata = open(pdffile,"rb").read()

  response.headers['Content-Type']='application/pdf' 

  return response.stream(cStringIO.StringIO(pdfdata), attachment=True, 
filename='languages.pdf') 

  elif form.errors:

  response.flash = 'form has errors'

 

  response.title = 'All Languages'

  return dict(form=form)

 
The second Problem i didn't solve yet, i Need to make a refresh on my 
sqlform.factory after the PDF file was displayed.

Thanks everybody for helping.


Am Mittwoch, 4. November 2015 01:38:15 UTC+1 schrieb Dave S:

>
>
> On Tuesday, November 3, 2015 at 3:30:59 PM UTC-8, Karl Florian wrote:
>>
>> No it didn't work on the web.
>> local Linux and Windows worked fine.
>> *I am using str(os.path.join(request.folder, 'tex', 'languages.tex')) to 
>> set the path to my files.*
>>
>> I am using Massimiliano's code to start my pdf's.
>> But i still have the 2 Problems i mentioned before.
>>
>
> I'm not sure about the button problem, but response.stream's filename 
> parameter should help with the ugly name.  
>
>
>  
>
>>
>> Am Dienstag, 3. November 2015 23:31:07 UTC+1 schrieb Dave S:
>>
>>>
>>>
>>> On Tuesday, November 3, 2015 at 1:26:26 PM UTC-8, Karl Florian wrote:

 I think i found my own solution.
 Wo ever has the same Problem, try this!!!

 import webbrowser 
 webbrowser.open_new(r'file://C:\path\to\file.pdf')


 It works just the way i Need it.


>>>
>>> I'm glad it works for you, but it won't work on a lot of systems (Linux 
>>> systems usually don't know what "C:" means, and their slashes are forward 
>>> leaning).
>>>
>>> You might look at using response.stream, 
>>>
>>
> [sorry, careless reading on the first pass]
>  
>
>> which has an option for setting a filename (sets the header field 
>>> "Content-Disposition"), and the browser should send that to a sensible 
>>> place, like the Downloads directory.
>>>
>>> >> http://web2py.com/books/default/chapter/29/04/the-core?search=content-type#response
>>> >
>>>
>>> /dps
>>>
>>>  
>>>



 Am Dienstag, 3. November 2015 16:38:06 UTC+1 schrieb Karl Florian:

>
> Hi Massimiliano,
> it works thank you!
>
> However there are 2 things i do not like:
>
> 1) My PDF File is renamed to the same as my Controller function Name 
> plus a number and *without the Extension .pdf*. 
> Example:* printlanguages+cd123452*
>
> 2) After the *"return response.stream()"* my *submit button* that 
> started the Output remains pressed until i refresh the url-page manually.
>
> Is there a way to Redirect to the URL after the pdf file was displayed?
>
> Do you or does anybody else have a solution for this?
>
>
> Am Dienstag, 3. November 2015 12:02:05 UTC+1 schrieb Massimiliano:
>
>> Try this way to display your pdf:
>>
>> def yourcontroller()
>> # generate pdf 
>> . . . 
>> import cStringIO
>> data = open(filename,"rb").read()
>> response.headers['Content-Type']='application/pdf' 
>> return response.stream(cStringIO.StringIO(data))  
>>
>>
>>
>>
>> On Mon, Nov 2, 2015 at 4:29 PM, Karl Florian  
>> wrote:
>>
>>> Hi,
>>> i am a newby to web2py and need some help dislaying label in my 
>>> application.
>>>  
>>> I’m using Latex and PSTricks to create my barcode label.pdf files. 
>>> The problem is, everthing works ok on local Windows or Ubuntu but 
>>> not from my Linux-VServer (WEbServer).
>>> The label.pdf is created but not displayed.
>>>
>>> This my sourccode after the place where i creating my label.pdf file:
>>> //
>>> This does not work on webserver (only in local Systems):
>>>  ...
>>> os.system('latex label.tex')
>>> time.sleep(0.1)
>>> if sys.platform == "win32":
>>>  os.system('dvips -o label-pics.ps label.dvi')
>>> os.system('ps2pdf awblabel-pics.ps label.pdf')
>>>os.startfile('label.pdf')
>>> else:
>>> # os.system('dvipdf label.dvi')
>>> os.system('dvips -o awblabel-pics.ps label.dvi')
>>> os.

Re: [web2py] Web2py - Babel

2015-11-04 Thread Mirek Zvolský
This is new for me, I have read this chapter for much older framework 
version.
It looks good but I need to study this system more to decide what is 
better, if the standard gettext/babel system or the Web2py solution.
Thank you.



Dne úterý 3. listopadu 2015 11:22:50 UTC+1 Vinicius Assef napsal(a):
>
> This can help you: 
> http://web2py.com/books/default/chapter/29/04/the-core#Pluralization-engine 
>
> -- 
> Vinicius Assef 
>
>
>
>
> On 3 November 2015 at 07:42, Mirek Zvolský > 
> wrote: 
> > Uses somebody Web2py with Flask-Babel or with Babel ? 
> > I think there is problem with Web2py translation system that the support 
> for 
> > plural is poor because there are languages with 2 forms of plural. But 
> maybe 
> > I misunderstand the translation system of Web2py ? 
> > 
> > -- 
> > Resources: 
> > - http://web2py.com 
> > - http://web2py.com/book (Documentation) 
> > - http://github.com/web2py/web2py (Source code) 
> > - https://code.google.com/p/web2py/issues/list (Report Issues) 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "web2py-users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to web2py+un...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

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


[web2py] web2py and python3

2015-11-04 Thread Jim Gregory
I know this has come up in the past, but it hasn't been asked in a while. 

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

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

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

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


[web2py] Re: Submissão Python Brasil 11

2015-11-04 Thread Matheus Cardoso
Ari613, o que chamo de framework de nicho é devido a natureza do web2py, 
embora ele tenha influências pesadas de outros frameworks Python, como o 
próprio Django. Mas se você parar para olhar, o web2py tem características 
que o diferenciam bastante de outros frameworks full stack, começando pelo 
PyDAL (alguém conhece algum que não use ORM, fora o web2py?). Coloco ainda 
os migrations automáticos e o, até agora, suportável overhead de os models 
serem sempre executados a cada request, o fato de ele não ser baixado pelo 
pip (isso rende uma discussão daquelas), o uso de Python nas views (em vez 
do clássico Jinja2 ou outro template existente no mercado) e muito mais. 
Isso o coloca, na minha visão, num lugar peculiar (nem acima e nem abaixo, 
pois não é esse o ponto aqui) frente aos demais frameworks da mesma classe 
(full stack). A "incubação" é o uso pesado em projetos pessoais, 
freelancers (como eu) ou uso interno em empresas (como já fiz também) e não 
divulgar para a comunidade - basicamente é isso.  Ah, e sobre a migração 
para o Flask, eu não acho que seja uma questão de ser melhor ou não (não há 
balas de prata, senhores), mas a abordagem minimalista. Eu também quero 
aprender Flask (e olhe que eu tenho total antipatia pelo seu criador por 
causa de uns flamewares dele contra o web2py no Reddit - tem uma discussão 
dele com o Massimo que é épica), mas não por estar descontente com o 
web2py, mas para conhecer uma abordagem não full-stack (mas isso sou eu). 

Quanto à comunidade, faço um mea culpa também. Na região onde morava, eu 
era referência de Python e web2py na cidade inteira (quase 700k de 
habitantes), mas pouco fazia para o resto da comunidade no país. 
Coincidentemente ao clamor do Vinicius, estou escrevendo um post sobre 
*multi-table 
update form* para me forçar a contribuir para a comunidade e ajudar outros, 
porque eu me bati numa coisa que eu tinha resolvido anos atrás e tinha 
esquecido (achei posts meus na lista mundial de usuários e "eu" não 
consegui me ajudar hoje - rs). 

Ovidio Marinho, você resumiu minha vida de palestras sobre o web2py (já fiz 
algumas, mas todas aqui na Bahia): eu era um alienígena e os caras com a 
expressão de "que porra de ferramenta é essa que esse cara ta falando?".  E 
todos eram do "mundo" Django ou Flask. Quanto ao livro, é um problema do 
jeito que era (não sei se mudou hoje) feito. Eu fiz vários PRs e nunca 
foram aceitos ou comentados, muito por causa da licença do livro e como o 
Massimo e demais controlavam as mudanças. Na época eu era bem iniciante e o 
que eu podia contribuir era com meu inglês e não rolou - o que me 
desmotivou também (mas sem desculpas). 

Mas um coisa me preocupa. Eu acompanho ativamente as discussões no github, 
e as duas listas mundiais do web2py e vi muitas vezes o Niphlod e o 
Anthony, contribuidores core do framework, se queixando que cada vez mais 
estava difícil manter o web2py. Some isso ao problema da comunidade local, 
mundial, falta de divulgação e, se nada mudar, não é difícil de prever o 
que vai acontecer. 

E um disclaimer: eu uso Django no dia a dia no meu trabalho, mas para meus 
freelas, é o web2py sem pestanejar. Mas ele tem muito a melhorar, 
principalmente em ser mais agradável a comunidade em geral (pip, estou 
olhando para você), melhorar a documentação (ela no geral é muito boa, mas 
quando você se aprofunda no uso, o source é o que salva), deploys mais 
claros e simplificados (no Openshift para fazer um script de deploy - 
embora hoje já exista um não oficial - é um parto e os scripts no contrib 
precisam de um olhar bem crítico para entender o que está sendo feito), 
dentre outros. 

#naodeixeoweb2pymorrer :)


On Monday, November 2, 2015 at 10:17:06 AM UTC-3, Ovidio Marinho wrote:
>
>
> Bom Dia Senhores,
>
> Acho que no brasil hoje temos mais de 5 mil usuarios do framework Web2py, 
> não tenho isso preciso , mas seria uma boa ideia, levantar e publicar, que 
> seja menos esta conta, não nos envergonharia ficar de fora de uma Python 
> Brasil, sendo o framework que está entre os cinco mais utilizados em 
> Python, não estou aqui pedindo para alguém submeter nada, só acho que a 
> comunidade deveria ter planejado e colocado algo. Sabemos da Crise 
> Financeira que atravessamos e os palestrantes mais distantes não tem 
> realmente condições proprias de arcar sozinho com as despesas, mas pelo que 
> me parece tem gente que domina o framework ai perto da regiao do evento. 
> Fica aqui o meu registro. 
>
> Obrigado!
>
>
>
>[image: http://itjp.net.br] 
>  http://itjp.net.b r
>   *Ovidio Marinho Falcao Neto*
>  ovid...@gmail.com 
> Brasil
>  
>

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

[web2py] Re: Putting time in a string

2015-11-04 Thread Alfonso Serra
you are overwriting t and not converting back to string 
session.time = t

-- 
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] auth tables not visible in appadmin

2015-11-04 Thread Red Beard
Hi,

My problem is that the auth tables do not appear in appadmin, though the 
system allows me to register users, and it seems to remember them.



I am following the example in the book (chapter 3, overview: 
http://www.web2py.com/books/default/chapter/29/03/overview)

I have left the model db.py:

from gluon.tools import Auth, Service, PluginManager

auth = Auth(db)
service = Service()
plugins = PluginManager()

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)


In front of some functions, the controller, default.py has:

@auth.requires_login()


And this seems to work, asking someone not logged in to log in.

Any ideas please? At the moment if I try and reference any of these auth tables 
the system throws up errors.


Many thanks

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


[web2py] Password protecting a folder (subdomain)

2015-11-04 Thread digirew
Hello,

I have a folder (html files & png as images) that I would like to password 
protect and only have specified users access.

Can I set this up using web2py? or do they all need to be pages created in 
web2py?



Andrew

-- 
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] DAL returns string fields not as unicode strings

2015-11-04 Thread Dandelion Mine
Hello!
According to Web2py book, 'by default web2py uses utf8 character encoding 
for databases'. I get the contrary results: there are fields with type 
'string', mysql shows that they have collation utf8_general_ci, but when I 
select them with DAL, the type of returned fields are 'str', not 'unicode'.

db.define_table('customers',
Field('name', 'string'))

+---+--+-+--
| Field | Type | Collation   | Null | Key | 
+---+--+-+--+
| name  | varchar(512) | utf8_general_ci | 

print type(db(db.tradera_customers).select().first().name)


I tried to remove *.table in databases and to use db_codec parameter for 
DAL, but nothing changed.

Web2py version 2.9.11-stable, Python 2.7.9, MySQL ver 14.14 Distrib 5.5.40

Is it a known bug or I'm doing something wrong?
Thanks in advance.

-- 
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] Apache 2.4 - 403 Forbidden Issue

2015-11-04 Thread Barış Güvercin
Hello everyone,

I have newly installed Debian 8 and Apache 2.4 server. I run the script 
setup-web2py-ubuntu.sh (attached). And wsgihandler.py has +x permission. 
But when I connect server, I get '403 Forbidden' / 'You don't have 
permission to access / on this server.'
In apache's error log : 
 [access_compat:error] ... AH01797: client denied by server 
configuration: /home/www-data/web2py/wsgihandler.py

and access log :
  "GET / HTTP/1.1" 403 701


Thanks in advance

-- 
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.
echo "This script will:
1) install all modules need to run web2py on Ubuntu 14.04
2) install web2py in /home/www-data/
3) create a self signed ssl certificate
4) setup web2py with mod_wsgi
5) overwrite /etc/apache2/sites-available/default
6) restart apache.

You may want to read this script before running it.

Press a key to continue...[ctrl+C to abort]"

read CONFIRM

#!/bin/bash
# optional
# dpkg-reconfigure console-setup
# dpkg-reconfigure timezoneconf
# nano /etc/hostname
# nano /etc/network/interfaces
# nano /etc/resolv.conf
# reboot now
# ifconfig eth0

echo "installing useful packages"
echo "=="
apt-get update
apt-get -y install ssh
apt-get -y install zip unzip
apt-get -y install tar
apt-get -y install openssh-server
apt-get -y install build-essential
apt-get -y install python
#apt-get -y install python2.5
apt-get -y install ipython
apt-get -y install python-dev
apt-get -y install postgresql
apt-get -y install apache2
apt-get -y install libapache2-mod-wsgi
apt-get -y install python2.5-psycopg2
apt-get -y install postfix
apt-get -y install wget
apt-get -y install python-matplotlib
apt-get -y install python-reportlab
apt-get -y install mercurial
/etc/init.d/postgresql restart

# optional, uncomment for emacs
# apt-get -y install emacs

# optional, uncomment for backups using samba
# apt-get -y install samba
# apt-get -y install smbfs

echo "downloading, installing and starting web2py"
echo "==="
cd /home
mkdir www-data
cd www-data
rm web2py_src.zip*
wget http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
mv web2py/handlers/wsgihandler.py web2py/wsgihandler.py
chown -R www-data:www-data web2py

echo "setting up apache modules"
echo "="
a2enmod ssl
a2enmod proxy
a2enmod proxy_http
a2enmod headers
a2enmod expires
a2enmod wsgi
a2enmod rewrite  # for 14.04
mkdir /etc/apache2/ssl

echo "creating a self signed certificate"
echo "=="
openssl genrsa 1024 > /etc/apache2/ssl/self_signed.key
chmod 400 /etc/apache2/ssl/self_signed.key
openssl req -new -x509 -nodes -sha1 -days 365 -key /etc/apache2/ssl/self_signed.key > /etc/apache2/ssl/self_signed.cert
openssl x509 -noout -fingerprint -text < /etc/apache2/ssl/self_signed.cert > /etc/apache2/ssl/self_signed.info

echo "rewriting your apache config file to use mod_wsgi"
echo "="
echo '
WSGIDaemonProcess web2py user=www-data group=www-data



  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

  CustomLog /var/log/apache2/access.log common
  ErrorLog /var/log/apache2/error.log



  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/self_signed.cert
  SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key

  WSGIProcessGroup web2py
  WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
  WSGIPassAuthorization On

  
AllowOverride None
Require all denied

  Require all granted

  

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2

  
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Require all granted
  

  CustomLog /var/log/apache2/ssl-access.log common
  ErrorLog /var/log/apache2/error.log

' > /etc/apache2/sites-available/default.conf  # FOR 14.04

sudo rm /etc/apache2/sites-enabled/*# FOR 14.04
sudo a2ensite default   # FOR 14.04

# echo "setting up PAM"
# echo ""
# sudo apt-get install pwauth
# sudo ln -s /etc/apache2/mods-available/authnz_external.load /etc/apache2/mods-enabled
# ln -s /etc/pam.d/apache2 /etc/pam.d/httpd
# usermod -a -G shadow www-data

echo "restarting apache"
echo ""

/etc/init.d/apache2 restart
cd /home/www-data/web2py
sudo -u www-data python -c "from gluon.widget import console; console();"
sudo -u www-data python -c "from gluon.main import save_password; save_password(raw_input('admin pass

[web2py] Simple Tutorial for using web2py with an html5 template

2015-11-04 Thread jack somber
I found a modern template at html5up.com, and am trying to use it with 
web2py.  Does anyone know of a tutorial for this.  Assets include css, js, 
fonts, sass.  Or is it as simple as uploading the assets and connecting 
them to the html?

Thanks. 

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


Re: [web2py] DAL alternatives

2015-11-04 Thread Massimo Di Pierro
Something like this was already implemented 4 years ago when we write a 
compatibility layer between Django and web2py:

http://web2py.com/AlterEgo/default/download/document.file.08621820-64d8-4db5-a85c-569a647a4437.py

Perhaps you can take some of that code and re-adapt it.


On Monday, 2 November 2015 08:50:34 UTC-6, Carlos Cesar Caballero wrote:
>
> The dal is a very good piece of software, and it can done practically 
> everything that any orm can do, but in my opinion, the problem is not what 
> we can do, but how we do it, for example, we have places, and the places 
> have reviews, it will be something like this:
>
> db.define_table('review',   Field('author'),   Field('valuea', 'int'),   
> Field('valueb', 'int'),   Field('valuec', 'int'),   Field('place','reference 
> place'))
>
> db.define_table('place',   Field('name'),   Field('description'))
>
> It's clean, there is no problem, but now we need to get the average on a 
> review values, and the average of all places reviews, the we get something 
> like this:
>
> def get_review_average(row):
> # all the code...# ...return value
>
> db.define_table('review',   Field('author'),   Field('valuea', 'int'),   
> Field('valueb', 'int'),   Field('valuec', 'int'),   Field('place','reference 
> place'))
>Field.Virtual('value', get_review_average))
> def get_place_reviews_average(row):
> # all the code calling review.value# ...return value
>
> db.define_table('place',   Field('name'),   Field('description'),   
> Field.Virtual('value', get_place_reviews_average))
>
> ok, now is not so clean, the "functions" are before the "variables" 
> declarations, we could add some validations, and we get functions code, 
> fields declarations, and validation code, in that order, when the model 
> grows, the code becomes more difficult to maintain, hardly if the person is 
> not who wrote the code.
> Now let's see some weppy-like syntax:
>
> class Review:
> author = Field()
> value = Field('int')
> valuea = Field('int')
> valueb = Field('int')
> place = Field('reference place')
>
> def get_average(row):
> # all the code...# ...return value
> class Place:
> name = Field()
> description = Field()
>
> def get_place_reviews_average(row):
> # all the code# ...return value
>
> db.define_models(Review, Place)
>
> Now the code has a more natural structure, first variables and later 
> functions, we dont care the order, because at the end we declare it using 
> the define_models() function, and we can use inheritance simply like this:
>
> class OtherReview(Review):
> valuebc = Field('int')
>
> Now the code is easier to maintain, and easier to reuse, we only need to 
> copy class files, and extend from them.
>
> This is not an orm, is just current pyDAL with an alternative structure 
> for table declarations.
>
> About the objects, if we could have real orm functionality, we could do 
> things like:
>
> object = db.mytable[id]object.name = "the name"object.save()
>
> or
>
> db.mytable.save(object)
>
> The non persistent variables is other thing, in some cases we need to use 
> non persistent variables, like flags, with the virtual or method fields, we 
> can define non persistent values, but we can't edit them.
>
> Greetings.
>
>
> El 30/10/15 a las 15:34, Anthony escribió:
>
> On Friday, October 30, 2015 at 3:10:29 PM UTC-4, Carlos Cesar Caballero 
> wrote: 
>>
>> We could use object oriented modeling,
>>
>
> Yes, but the question is, what exactly does that mean to you, and how 
> would it improve things over the current DAL? Can you share a specific 
> example, possibly including pseudo-code?
>
> Also, are you saying you want an ORM, or are you using "object oriented" 
> more generically. If the latter, of course the DAL is already "object 
> oriented" in that most of the API involves instantiating objects and 
> calling methods on them.
>  
>
>> we could save our objects directly to the database
>>
>
> What do you mean by "objects" here? Are you saying you want to save native 
> Python objects to the database? If so, that would be a feature of the 
> database rather than the abstraction layer interacting with it. Of course, 
> web2py does allow you to store arbitrary objects to any database if they 
> can be pickled or otherwise serialized and deserialized. Can you give an 
> example, and maybe point to how some other favored abstraction layer 
> handles it (e.g., SQLAlchemy)?
>  
>
>> , we could declare non persistent variables in objects
>>
>
> Not sure what you mean by this. Is this something that can be handled via 
> virtual fields or method fields?
>  
>
>> , we could have a better code structure in our apps, we could maintain 
>> large models easily
>>
>
> Can you be more specific? In web2py, nothing stops you from breaking up 
> model code into multiple modules.
>  
>
>> , we could reuse or extend model classes easily
>>
>
> This would be one benefit of a

[web2py] Re: About static files in markmin

2015-11-04 Thread Massimo Di Pierro
MARKMIN itself does not mess with paths. It just render the markup to HTML. 
Paths are framework/application/routes dependent therefore there cannot be 
a generic syntax in markmin that works in every case. The same problem 
happens when the hostname changes.

In auth.wiki we solve the problem by allowing this syntax: @args where 
@[hostname]/[app]/[controller]/[function]/[args] and each part [...] can be 
omitted. if omitted, it is put in by the server when generating the 
response, before markmin is rendered.


On Tuesday, 3 November 2015 01:58:46 UTC-6, mweissen wrote:
>
> I want to show a picture in a markmin file.
> This is my markmin text:
>
> [[Description /myapp/static/mypicture.png center]]
>
>
> Works fine, but if I want to use the same text in another application I 
> have to change it to
>  
>
> ​[[Description /myotherapp/static/mypicture.png center]]​
>
>
> It is possible to use something generic like  ./static/mypicture.png ?
>
> Regards, Martin
>
>
>

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

2015-11-04 Thread Massimo Di Pierro
There will be a new framework similar to web2py for python 3. web2py has to 
be backward compatible and it is pointless to port it to python 3. 

On Wednesday, 4 November 2015 06:25:40 UTC-6, Jim Gregory wrote:
>
> I know this has come up in the past, but it hasn't been asked in a while. 
>
> Is there ever going to be a usable and maintained Python3-compatible fork 
> of web2py?
>
> The latest edition of Fedora now ships with Python3 by default. It's the 
> default version used in Django's tutorial.
>
> I'm not using Python3 now, but I can see the day when I inevitably will. I 
> don't want to invest the time in a framework if I know I'll have to abandon 
> it later.
>

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


[web2py] Re: test for integer in form

2015-11-04 Thread Massimo Di Pierro
I am lost in this thread. Can you state your problem once more with a 
couple of examples. I am pretty sure try... except is wrong. The 
requires=IS_INT_IN_RANTE(minumum,maximum) can also be set in controllers, 
does not have to be set in models. Moreover 

try:
 int(s)
except:
 pass

is the worst possible thing. Python has s.isdigit() or if you need to allow 
for a sign re.compile('^[-+]?\d+$').match(s).

On Tuesday, 3 November 2015 16:26:17 UTC-6, Alex Glaros wrote:
>
> This is wrong:
>
> how about a requires clause that is some kind of lambda that requires any 
> non-numeric?  Is that possible?how about a requires clause that is some 
> kind of lambda that requires any non-numeric?  Is that possible? db.
> auth_group.role.requires=role contains ('a', 'b', 'c', etc)
>
> because doesn't handle foreign languages. 
>
> So if can't use a requires clause, then am stuck with try, which works...
>

-- 
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] bootstrap3 formstyle checkboxes

2015-11-04 Thread Richard Vézina
In the book it mention that radio and checkboxes widget have different
style attribute, your issue is probably related to this particularity of
these widget ?

Quote from the book :
Widgets are helper factories and their first two arguments are always field
 and value. The other arguments can include normal helper attributes such
as _style, _class, etc. Some widgets also take special arguments. In
particular SQLFORM.widgets.radio and SQLFORM.widgets.checkboxestake a
style argument
(not to be confused with _style) which can be set to "table", "ul", or
"divs" in order to match the formstyle of the containing form.

On Wed, Nov 4, 2015 at 2:27 AM, Gary Cowell  wrote:

> That the labels for boolean fields are consistent in appearance with the
> labels for other classes of field.
>
> So, emboldened and on the left.
>
> On Tuesday, 3 November 2015 16:28:15 UTC, Richard wrote:
>>
>> What is the expected behavior?
>>
>> On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell  wrote:
>>
>>> Web2py version:
>>> >>> import gluon.widget
>>> >>> print gluon.widget.ProgramVersion
>>> Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
>>>
>>>
>>> When using bootstrap3_inline for forms, the checkbox lables are not
>>> correctly styled:
>>>
>>>
>>>
>>>
>>> This is my form code:
>>>
>>> form=SQLFORM.factory(
>>> Field('SystemName',label='System Name', length=80, required=True
>>> , requires=IS_NOT_EMPTY()),
>>> Field('Image',label='Base System', requires=IS_IN_SET(imageList,
>>> zero='Choose Base System')),
>>> Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,
>>> dbcccs.v_clients.cc_customer_id,'%(cc_name)s 
>>> (%(cc_customer_id)s)',zero='Choose
>>> Customer')),
>>> Field('publicsystem','boolean',label='Public', default='False'),
>>> Field('customports','boolean',label='Custom Ports?', default=
>>> 'False'),
>>> Field('customportlist',label='Custom Port List', required=False,
>>> requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited
>>> port list, e.g. 5001,5050,9127")),
>>> formstyle='bootstrap3_inline'
>>> )
>>>
>>>
>>> And this code looks suspicious in gluon/sqlhtml.py:
>>>
>>> def formstyle_bootstrap3_inline_factory(col_label_size=3):
>>> """ bootstrap 3 horizontal form layout
>>>
>>> Note:
>>> Experimental!
>>> """
>>> def _inner(form, fields):
>>> form.add_class('form-horizontal')
>>> label_col_class = "col-sm-%d" % col_label_size
>>> col_class = "col-sm-%d" % (12 - col_label_size)
>>> offset_class = "col-sm-offset-%d" % col_label_size
>>> parent = CAT()
>>> for id, label, controls, help in fields:
>>> # wrappers
>>> _help = SPAN(help, _class='help-block')
>>> # embed _help into _controls
>>> _controls = DIV(controls, _help, _class=col_class)
>>> if isinstance(controls, INPUT):
>>> if controls['_type'] == 'submit':
>>> controls.add_class('btn btn-primary')
>>> _controls = DIV(controls, _class="%s %s" % (
>>> col_class, offset_class))
>>> if controls['_type'] == 'button':
>>> controls.add_class('btn btn-default')
>>> elif controls['_type'] == 'file':
>>> controls.add_class('input-file')
>>> elif controls['_type'] in ('text', 'password'):
>>> controls.add_class('form-control')
>>> elif controls['_type'] == 'checkbox':
>>> label['_for'] = None
>>> label.insert(0, controls)
>>> _controls = DIV(DIV(label, _help, _class="checkbox"
>>> ),
>>> _class="%s %s" % (offset_class,
>>> col_class))
>>> label = ''
>>> elif isinstance(controls, (SELECT, TEXTAREA)):
>>> controls.add_class('form-control')
>>>
>>> The checkbox control type is doing something odd with labels.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book (Documentation)
>>> - http://github.com/web2py/web2py (Source code)
>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@go

[web2py] Re: About static files in markmin

2015-11-04 Thread Martin Weissenboeck
Thank you very much - this solves my problem: I want to use these files in
a wiki.
It has not been clear for me whether "@args" will be resolved first or
"[[...]]".

2015-11-04 15:31 GMT+01:00 Massimo Di Pierro :

> MARKMIN itself does not mess with paths. It just render the markup to
> HTML. Paths are framework/application/routes dependent therefore there
> cannot be a generic syntax in markmin that works in every case. The same
> problem happens when the hostname changes.
>
> In auth.wiki we solve the problem by allowing this syntax: @args where
> @[hostname]/[app]/[controller]/[function]/[args] and each part [...] can be
> omitted. if omitted, it is put in by the server when generating the
> response, before markmin is rendered.
>
>
> On Tuesday, 3 November 2015 01:58:46 UTC-6, mweissen wrote:
>>
>> I want to show a picture in a markmin file.
>> This is my markmin text:
>>
>> [[Description /myapp/static/mypicture.png center]]
>>
>>
>> Works fine, but if I want to use the same text in another application I
>> have to change it to
>>
>>
>> ​[[Description /myotherapp/static/mypicture.png center]]​
>>
>>
>> It is possible to use something generic like  ./static/mypicture.png ?
>>
>> Regards, Martin
>>
>>
>>

-- 
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: Putting time in a string

2015-11-04 Thread Garry Smith
Hi
Thanks for the reply, the session.time was left in my mistake, 
I tried it without the session and it still gave me the same error, I have 
tried your suggestion and is working.
The only problem I am having know is the request.client is sending a ip of 
127.0.0.1, which ever client pc I use.
This is only being used on a intranet and should pick up a 10.1.2.* as the 
ip.

Thanks

G Smith

On Wednesday, 4 November 2015 13:41:48 UTC, Alfonso Serra wrote:
>
> you are overwriting t and not converting back to string 
> session.time = t
>
> the better if you format the variables like:
> subject= "Message From: %s, %s, %s" % (name, bod, t)
>
> This way, python will take care of the conversion for you.
>

On Wednesday, 4 November 2015 13:41:48 UTC, Alfonso Serra wrote:
>
> you are overwriting t and not converting back to string 
> session.time = t
>
> the better if you format the variables like:
> subject= "Message From: %s, %s, %s" % (name, bod, t)
>
> This way, python will take care of the conversion for 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/d/optout.


Re: [web2py] bootstrap3 formstyle checkboxes

2015-11-04 Thread Gary Cowell
Ah, I see that my 'checkbox' is actually this widget by default:

SQLFORM.widgets.boolean.widget

So then it's in fact the boolean.widget that isn't being correctly styled.

Still trying to work out where the styling for boolean.widget comes from. 

Still think it's something that will be relvealed by sqlhtml.py , but not 
nailed it yet.

At least now I know which widget my form is using.

It has consistent styling in the stacked formstyle, just not in the inine 
formstyle.



On Wednesday, 4 November 2015 14:52:39 UTC, Richard wrote:
>
> In the book it mention that radio and checkboxes widget have different 
> style attribute, your issue is probably related to this particularity of 
> these widget ?
>
> Quote from the book :
> Widgets are helper factories and their first two arguments are always 
> field and value. The other arguments can include normal helper attributes 
> such as _style, _class, etc. Some widgets also take special arguments. In 
> particular SQLFORM.widgets.radio and SQLFORM.widgets.checkboxestake a 
> style argument (not to be confused with _style) which can be set to 
> "table", "ul", or "divs" in order to match the formstyle of the 
> containing form.
>
> On Wed, Nov 4, 2015 at 2:27 AM, Gary Cowell  > wrote:
>
>> That the labels for boolean fields are consistent in appearance with the 
>> labels for other classes of field.
>>
>> So, emboldened and on the left. 
>>
>> On Tuesday, 3 November 2015 16:28:15 UTC, Richard wrote:
>>>
>>> What is the expected behavior?
>>>
>>> On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell  wrote:
>>>
 Web2py version:
 >>> import gluon.widget
 >>> print gluon.widget.ProgramVersion
 Version 2.12.3-stable+timestamp.2015.08.19.00.18.03


 When using bootstrap3_inline for forms, the checkbox lables are not 
 correctly styled:




 This is my form code:

 form=SQLFORM.factory(
 Field('SystemName',label='System Name', length=80, required=
 True, requires=IS_NOT_EMPTY()),
 Field('Image',label='Base System', requires=IS_IN_SET(imageList
 ,zero='Choose Base System')),
 Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,
 dbcccs.v_clients.cc_customer_id,'%(cc_name)s (%(cc_customer_id)s)',zero
 ='Choose Customer')),
 Field('publicsystem','boolean',label='Public', default='False'
 ),
 Field('customports','boolean',label='Custom Ports?', default=
 'False'),
 Field('customportlist',label='Custom Port List', required=False
 , requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma delimited 
 port list, e.g. 5001,5050,9127")),
 formstyle='bootstrap3_inline'
 )


 And this code looks suspicious in gluon/sqlhtml.py:

 def formstyle_bootstrap3_inline_factory(col_label_size=3):
 """ bootstrap 3 horizontal form layout

 Note:
 Experimental!
 """
 def _inner(form, fields):
 form.add_class('form-horizontal')
 label_col_class = "col-sm-%d" % col_label_size
 col_class = "col-sm-%d" % (12 - col_label_size)
 offset_class = "col-sm-offset-%d" % col_label_size
 parent = CAT()
 for id, label, controls, help in fields:
 # wrappers
 _help = SPAN(help, _class='help-block')
 # embed _help into _controls
 _controls = DIV(controls, _help, _class=col_class)
 if isinstance(controls, INPUT):
 if controls['_type'] == 'submit':
 controls.add_class('btn btn-primary')
 _controls = DIV(controls, _class="%s %s" % (
 col_class, offset_class))
 if controls['_type'] == 'button':
 controls.add_class('btn btn-default')
 elif controls['_type'] == 'file':
 controls.add_class('input-file')
 elif controls['_type'] in ('text', 'password'):
 controls.add_class('form-control')
 elif controls['_type'] == 'checkbox':
 label['_for'] = None
 label.insert(0, controls)
 _controls = DIV(DIV(label, _help, _class="checkbox"
 ),
 _class="%s %s" % (offset_class, 
 col_class))
 label = ''
 elif isinstance(controls, (SELECT, TEXTAREA)):
 controls.add_class('form-control')

 The checkbox control type is doing something odd with labels.





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

Re: [web2py] Re: web2py and python3

2015-11-04 Thread António Ramos
@massimo
When will it be available ?


2015-11-04 14:38 GMT+00:00 Massimo Di Pierro :

> There will be a new framework similar to web2py for python 3. web2py has
> to be backward compatible and it is pointless to port it to python 3.
>
>
> On Wednesday, 4 November 2015 06:25:40 UTC-6, Jim Gregory wrote:
>>
>> I know this has come up in the past, but it hasn't been asked in a while.
>>
>> Is there ever going to be a usable and maintained Python3-compatible fork
>> of web2py?
>>
>> The latest edition of Fedora now ships with Python3 by default. It's the
>> default version used in Django's tutorial.
>>
>> I'm not using Python3 now, but I can see the day when I inevitably will.
>> I don't want to invest the time in a framework if I know I'll have to
>> abandon it later.
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+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] Returning a controller function with an integer causes Thread issues

2015-11-04 Thread Calvin
Hi

I was working on the a controller function where the end result was the row 
id following a 

def insert_record()
  id= db[f].insert(**data) operaton
  return id

As it turns out, this works without a hitch on my mac running python 2.7.10 
and Web2py Version 2.9.12-beta+timestamp.2015.01.12.21.00.43, while on a 
Centos 7 machine with python 2.7.5 and the head web2py Version 
2.12.3-stable+timestamp.2015.08.18.19.14.07, I could not for the longest 
time get the AJAX POST call to return the id of the inserted row from the 
Centos machine while it worked perfectly fine from my mac.

After much frustration, I am happy to share that I have resolved this by 
casting the return id into a string:

def insert_record()
  id= db[f].insert(**data) operaton
  return str(id)


Sharing this if it helps save some one else some time!

C

-- 
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: Simple Tutorial for using web2py with an html5 template

2015-11-04 Thread Anthony
I would recommend reading the layout 
 
section of the book and take a look at the layout.html file included in the 
welcome app. Just use the template you have found as the starting point for 
your layout, and add in the relevant web2py related stuff where appropriate 
(e.g., include web2py_ajax.html in the head; possibly include 
response.flash, response.menu, and auth.toolbar at the appropriate places 
in the markup, depending on your needs; etc.).

Anthony

On Wednesday, November 4, 2015 at 9:19:41 AM UTC-5, jack somber wrote:
>
> I found a modern template at html5up.com, and am trying to use it with 
> web2py.  Does anyone know of a tutorial for this.  Assets include css, js, 
> fonts, sass.  Or is it as simple as uploading the assets and connecting 
> them to the html?
>
> Thanks. 
>

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


[web2py] Re: auth tables not visible in appadmin

2015-11-04 Thread Anthony
Can you pack and attach a minimal app that displays the problem?

On Wednesday, November 4, 2015 at 9:19:41 AM UTC-5, Red Beard wrote:
>
> Hi,
>
> My problem is that the auth tables do not appear in appadmin, though the 
> system allows me to register users, and it seems to remember them.
>
>
>
> I am following the example in the book (chapter 3, overview: 
> http://www.web2py.com/books/default/chapter/29/03/overview)
>
> I have left the model db.py:
>
> from gluon.tools import Auth, Service, PluginManager
>
> auth = Auth(db)
> service = Service()
> plugins = PluginManager()
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=False, signature=False)
>
>
> In front of some functions, the controller, default.py has:
>
> @auth.requires_login()
>
>
> And this seems to work, asking someone not logged in to log in.
>
> Any ideas please? At the moment if I try and reference any of these auth 
> tables the system throws up errors.
>
>
> Many thanks
>
>

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


Re: [web2py] bootstrap3 formstyle checkboxes

2015-11-04 Thread Richard Vézina
When you want control over widget that are manage by sqlform, you better
set the widget at the model level and pass you preferences of display... If
it still not working you can implement your own widget where you are free
to style it the way you want even change the display framework completly...

Richard

On Wed, Nov 4, 2015 at 10:26 AM, Gary Cowell  wrote:

> Ah, I see that my 'checkbox' is actually this widget by default:
>
> SQLFORM.widgets.boolean.widget
>
> So then it's in fact the boolean.widget that isn't being correctly styled.
>
> Still trying to work out where the styling for boolean.widget comes from.
>
> Still think it's something that will be relvealed by sqlhtml.py , but not 
> nailed it yet.
>
> At least now I know which widget my form is using.
>
> It has consistent styling in the stacked formstyle, just not in the inine 
> formstyle.
>
>
>
> On Wednesday, 4 November 2015 14:52:39 UTC, Richard wrote:
>>
>> In the book it mention that radio and checkboxes widget have different
>> style attribute, your issue is probably related to this particularity of
>> these widget ?
>>
>> Quote from the book :
>> Widgets are helper factories and their first two arguments are always
>> field and value. The other arguments can include normal helper
>> attributes such as _style, _class, etc. Some widgets also take special
>> arguments. In particular SQLFORM.widgets.radio and
>> SQLFORM.widgets.checkboxestake a style argument (not to be confused with
>> _style) which can be set to "table", "ul", or "divs" in order to match
>> the formstyle of the containing form.
>>
>> On Wed, Nov 4, 2015 at 2:27 AM, Gary Cowell  wrote:
>>
>>> That the labels for boolean fields are consistent in appearance with the
>>> labels for other classes of field.
>>>
>>> So, emboldened and on the left.
>>>
>>> On Tuesday, 3 November 2015 16:28:15 UTC, Richard wrote:

 What is the expected behavior?

 On Tue, Nov 3, 2015 at 4:50 AM, Gary Cowell  wrote:

> Web2py version:
> >>> import gluon.widget
> >>> print gluon.widget.ProgramVersion
> Version 2.12.3-stable+timestamp.2015.08.19.00.18.03
>
>
> When using bootstrap3_inline for forms, the checkbox lables are not
> correctly styled:
>
>
>
>
> This is my form code:
>
> form=SQLFORM.factory(
> Field('SystemName',label='System Name', length=80, required=
> True, requires=IS_NOT_EMPTY()),
> Field('Image',label='Base System', requires=IS_IN_SET(
> imageList,zero='Choose Base System')),
> Field('Customer',label='Customer', requires=IS_IN_DB(dbcccs,
> dbcccs.v_clients.cc_customer_id,'%(cc_name)s (%(cc_customer_id)s)',
> zero='Choose Customer')),
> Field('publicsystem','boolean',label='Public', default='False'
> ),
> Field('customports','boolean',label='Custom Ports?', default=
> 'False'),
> Field('customportlist',label='Custom Port List', required=
> False, requires=IS_MATCH('^(\d+(,\d+)*)?$', error_message="Comma
> delimited port list, e.g. 5001,5050,9127")),
> formstyle='bootstrap3_inline'
> )
>
>
> And this code looks suspicious in gluon/sqlhtml.py:
>
> def formstyle_bootstrap3_inline_factory(col_label_size=3):
> """ bootstrap 3 horizontal form layout
>
> Note:
> Experimental!
> """
> def _inner(form, fields):
> form.add_class('form-horizontal')
> label_col_class = "col-sm-%d" % col_label_size
> col_class = "col-sm-%d" % (12 - col_label_size)
> offset_class = "col-sm-offset-%d" % col_label_size
> parent = CAT()
> for id, label, controls, help in fields:
> # wrappers
> _help = SPAN(help, _class='help-block')
> # embed _help into _controls
> _controls = DIV(controls, _help, _class=col_class)
> if isinstance(controls, INPUT):
> if controls['_type'] == 'submit':
> controls.add_class('btn btn-primary')
> _controls = DIV(controls, _class="%s %s" % (
> col_class, offset_class))
> if controls['_type'] == 'button':
> controls.add_class('btn btn-default')
> elif controls['_type'] == 'file':
> controls.add_class('input-file')
> elif controls['_type'] in ('text', 'password'):
> controls.add_class('form-control')
> elif controls['_type'] == 'checkbox':
> label['_for'] = None
> label.insert(0, controls)
> _controls = DIV(DIV(label, _help, _class=
> "checkbox"),
> _class="%s %s" % (offset_class,
> col_class))
> label = ''
>>

[web2py] Re: test for integer in form

2015-11-04 Thread Alex Glaros
I want to prevent users from choosing a db.auth_group.role name that is an 
integer because integer names for roles are reserved fro admin purposes.

Admin uses primary key of an organization or other entities as the 
db.auth_group.role name. This makes it effortless to manage permissions for 
hundreds of user organizations and entities.

If a user organization was allowed to create an integer-named 
db.auth_group.role like "54", then sometime in the future, there might 
another organization whose primary key is "54" and permissions for that org 
cannot be created.

Integer can be tested for outside of the create-record and edit-a-record 
mode using all kinds of python features. So I could create a separate 
function just to test for integer then copy that var as default value to 
the creating/editing a record input form. That is a little extra work, but 
you're right, it's better than the try/except method.

It would be simpler to test for integer in the create/edit mode with a 
"requires =" clause. But I can't figure out how Python detect-integer 
functions can be written as "requires =" clauses.

Something like this would be good:

db.auth_group.role.requires = not IS_INT_IN_RANGE(-sys.maxint -1, 
sys.maxint)

thanks,

Alex

-- 
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-users-brazil:8169] Re: Submissão Python Brasil 11

2015-11-04 Thread Ari Sobel
Opa, Matheus, muito obrigado pelas colocações. Sim. Não conheço nada de
outros frameworks, o web2py foi minha porta de entrada no mundo web (fora
uma curta incursão no PHP sem framework), por isso nao posso falar dos
outros. Mas os pontos fortes que ouço são principalmente o PyDal e usar
Python puro nas views (entre outros pontos que vc citou).

Legal também ver que alguem do teu nivel faz parte da comunidade, assim
como outros, na verdade, todos os que postaram algo aqui nessa thread, fora
eu, o que da segurança para os iniciantes como eu em saber que temos para
quem perguntar.

Mas pegando o gancho do Carlos Yamandu, onde ele pergunta se a falta de uma
ferramenta pode fazer diferença na atividade da comunidade. O Carlos citou
se ter um ERP poderia 'agitar mais a galera'. Particularmente a mim, é
interessante esse assunto. Pois sempre que pensamos em sistemas para
empresas, vem à cabeça esse tipo de ferramenta. Estou tomando coragem para
perguntar/sugerir.

Mas vai lá...

Gostando da idéia de ERP open-source em web2py, a pergunta seria:
A comunidade gostaria de criar um projeto desse?

Do meu lado, tenho já algo a oferecer/contribuir com esse possivel ERP.
Tenho um menu flexível baseado em tabelas e um pequeno admin pra gerir o
RBAC e os Menus (baseados em tabelas) da aplicação. Eu gostaria de abrir
algo desse código, mas apenas se mais um ou dois membros da lista tivessem
algo para contribuir imediatamente ao sistema. Teria algumas regras na
cabeça, mas essa thread não seria o local para falarmos disso.

Tendo uma ferramenta assim, um pequeno ERP modular, seria mais fácil
iniciar um sistema, e poderia agitar e atrair mais gente para a 'comunidade
we2py'.

O que acham?

abcs
Ari



Em 4 de novembro de 2015 11:07, Matheus Cardoso 
escreveu:

> Ari613, o que chamo de framework de nicho é devido a natureza do web2py,
> embora ele tenha influências pesadas de outros frameworks Python, como o
> próprio Django. Mas se você parar para olhar, o web2py tem características
> que o diferenciam bastante de outros frameworks full stack, começando pelo
> PyDAL (alguém conhece algum que não use ORM, fora o web2py?). Coloco ainda
> os migrations automáticos e o, até agora, suportável overhead de os models
> serem sempre executados a cada request, o fato de ele não ser baixado pelo
> pip (isso rende uma discussão daquelas), o uso de Python nas views (em vez
> do clássico Jinja2 ou outro template existente no mercado) e muito mais.
> Isso o coloca, na minha visão, num lugar peculiar (nem acima e nem abaixo,
> pois não é esse o ponto aqui) frente aos demais frameworks da mesma classe
> (full stack). A "incubação" é o uso pesado em projetos pessoais,
> freelancers (como eu) ou uso interno em empresas (como já fiz também) e não
> divulgar para a comunidade - basicamente é isso.  Ah, e sobre a migração
> para o Flask, eu não acho que seja uma questão de ser melhor ou não (não há
> balas de prata, senhores), mas a abordagem minimalista. Eu também quero
> aprender Flask (e olhe que eu tenho total antipatia pelo seu criador por
> causa de uns flamewares dele contra o web2py no Reddit - tem uma discussão
> dele com o Massimo que é épica), mas não por estar descontente com o
> web2py, mas para conhecer uma abordagem não full-stack (mas isso sou eu).
>
> Quanto à comunidade, faço um mea culpa também. Na região onde morava, eu
> era referência de Python e web2py na cidade inteira (quase 700k de
> habitantes), mas pouco fazia para o resto da comunidade no país.
> Coincidentemente ao clamor do Vinicius, estou escrevendo um post sobre 
> *multi-table
> update form* para me forçar a contribuir para a comunidade e ajudar
> outros, porque eu me bati numa coisa que eu tinha resolvido anos atrás e
> tinha esquecido (achei posts meus na lista mundial de usuários e "eu" não
> consegui me ajudar hoje - rs).
>
> Ovidio Marinho, você resumiu minha vida de palestras sobre o web2py (já
> fiz algumas, mas todas aqui na Bahia): eu era um alienígena e os caras com
> a expressão de "que porra de ferramenta é essa que esse cara ta falando?".
> E todos eram do "mundo" Django ou Flask. Quanto ao livro, é um problema do
> jeito que era (não sei se mudou hoje) feito. Eu fiz vários PRs e nunca
> foram aceitos ou comentados, muito por causa da licença do livro e como o
> Massimo e demais controlavam as mudanças. Na época eu era bem iniciante e o
> que eu podia contribuir era com meu inglês e não rolou - o que me
> desmotivou também (mas sem desculpas).
>
> Mas um coisa me preocupa. Eu acompanho ativamente as discussões no github,
> e as duas listas mundiais do web2py e vi muitas vezes o Niphlod e o
> Anthony, contribuidores core do framework, se queixando que cada vez mais
> estava difícil manter o web2py. Some isso ao problema da comunidade local,
> mundial, falta de divulgação e, se nada mudar, não é difícil de prever o
> que vai acontecer.
>
> E um disclaimer: eu uso Django no dia a dia no meu trabalho, mas para meus
> freelas, é o web2py sem pestanejar. M

[web2py] custom auth table email field set to unique=True accepts non unique values with different case.

2015-11-04 Thread arihant daga
In custom auth table even if email field is set to unique=true, if user 
inputs two different values different in case ex.( 'em...@gmail.com' and 
'em...@gmail.com' ) it will accepts both and will store both of them in 
database. Hence enabling a user to signup with the same email id multiple 
times with multiple usernames. 

-- 
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: custom auth table email field set to unique=True accepts non unique values with different case.

2015-11-04 Thread Anthony
unique=True is enforced by the database, not web2py, so it may be case 
sensitive depending the backend. Also, failures will result in a database 
error rather than a nice error message reported to the user in the UI. 
Instead, you should rely on validators to manage this:

Field('email', requires=[IS_EMAIL(), IS_LOWER(),
 IS_NOT_IN_DB(db, 'auth_user.email', error_message=
auth.messages.email_taken)]

The IS_LOWER() validator converts the email address to lower case (which is 
how it will then be stored), which effectively makes the lookup case 
insensitive. Note, the above is exactly the set of validators you get on 
the default email field when auth.settings.email_case_sensitive=True.

Anthony

On Wednesday, November 4, 2015 at 12:39:34 PM UTC-5, arihant daga wrote:
>
> In custom auth table even if email field is set to unique=true, if user 
> inputs two different values different in case ex.( 'em...@gmail.com' and '
> em...@gmail.com' ) it will accepts both and will store both of them in 
> database. Hence enabling a user to signup with the same email id multiple 
> times with multiple usernames. 
>

-- 
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] its possible get mac address?

2015-11-04 Thread Fabiano Almeida
Hi!

Web2py can obtain mac address from user?

Thanks in advance,

Fabiano.

-- 
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] decorator "Or" operator syntax

2015-11-04 Thread Alex Glaros
Only the first-named requirement gets executed when I use "or" in a 
decorator.

What is correct "or" syntax?

In below example, the first item works and the second is ignored.

@auth.requires_membership(request.get_vars.specificObjectID or 
'Engagement_Squared_Super_Admin')

In second example below, the first item works and second is is ignored.

@auth.requires((auth.has_membership('Engagement_Squared_Super_Admin') or 
(auth.has_membership(request.get_vars.specificObjectID

What is correct syntax for the "or" operator?

thanks,

Alex Glaros

Note: they correctly work independently when used as one-liners. E.g., 
@auth.requires_membership(request.get_vars.specificObjectID)

-- 
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: decorator "Or" operator syntax

2015-11-04 Thread Anthony
Are you saying that:

@auth.requires_membership(request.get_vars.specificObjectID)

allows access, but with the exact same query string (i.e., specificObjectID 
set to the same value in the URL query string):

@auth.requires(auth.has_membership('Engagement_Squared_Super_Admin') or
   auth.has_membership(request.get_vars.specificObjectID))

does not allow access? The condition in the latter should evaluate to True 
whenever the former is True. Maybe double check your code and that the test 
case (i.e., requested URL) is identical.

Also, when using @auth.requires() it is best to put any .has_membership or 
.has_permission checks inside a lambda so they will only be evaluated when 
the decorated function is actually called (otherwise they will be evaluated 
whenever any function in the controller is called).

Finally, the above approach doesn't seem secure, as it will allow an astute 
user to gain access as long as they have membership in at least one group 
(and know the name of the group). For example, I could request:

http://yourapp.com/default/private_function?specificObjectID=any_group_I_know_I_belong_to

Now I have access to private_function, regardless of what group(s) I belong 
to.

Anthony


On Wednesday, November 4, 2015 at 2:39:54 PM UTC-5, Alex Glaros wrote:
>
> Only the first-named requirement gets executed when I use "or" in a 
> decorator.
>
> What is correct "or" syntax?
>
> In below example, the first item works and the second is ignored.
>
> @auth.requires_membership(request.get_vars.specificObjectID or 
> 'Engagement_Squared_Super_Admin')
>
> In second example below, the first item works and second is is ignored.
>
> @auth.requires((auth.has_membership('Engagement_Squared_Super_Admin') or 
> (auth.has_membership(request.get_vars.specificObjectID
>
> What is correct syntax for the "or" operator?
>
> thanks,
>
> Alex Glaros
>
> Note: they correctly work independently when used as one-liners. E.g., 
> @auth.requires_membership(request.get_vars.specificObjectID)
>

-- 
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] its possible get mac address?

2015-11-04 Thread Carlos Cesar Caballero Díaz
Bassicly, the MAC address don't cross the routers, so, you can't get the 
mac address of a client from a external network server, you only can get 
the MAC of the last router. You could do some tweak using ARP, but only 
if the client and server are in the same subnet.


Greetings.


El 04/11/15 a las 14:30, Fabiano Almeida escribió:

Hi!

Web2py can obtain mac address from user?

Thanks in advance,

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




--
Este mensaje le ha llegado mediante el servicio de correo electronico que 
ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema 
Nacional de Salud. La persona que envia este correo asume el compromiso de usar 
el servicio a tales fines y cumplir con las regulaciones establecidas

Infomed: http://www.sld.cu/

--
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] Why won't web2py serve my .vcf file?

2015-11-04 Thread tim spear


I'm trying to let users download a .vcf file (vCard).

I copied myfile.vcf to the static folder. When I try going to 
www.myapp.com/static/myfile.vcf I get "invalid request" while other files 
in the static folder ending .js or .ico get served fine. Any ideas why it 
doesn't like .vcf or how to fix it?


Thanks  [also asked on Stackoverflow]

-- 
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: Password protecting a folder (subdomain)

2015-11-04 Thread Dave S
On Wednesday, November 4, 2015 at 6:19:41 AM UTC-8, digirew wrote:
>
> Hello,
>
> I have a folder (html files & png as images) that I would like to password 
> protect and only have specified users access.
>
> Can I set this up using web2py? or do they all need to be pages created in 
> web2py?
>
>
 You can use the auth mechanisms to require login and group membership 
before your controller will access the folder (if you're restricting the 
whole folder; that's the easy case).  If you are trying to restrict *some* 
files within a folder, you'd need a table somewhere (like in the db, since 
you already have a db) that tells you which files require login, and then 
apply the auth mechanisms
http://web2py.com/books/default/chapter/29/09/access-control>
and read at least through the group memberships.

If you want a *second*  password for particular files, you may be able to 
use the auth mechanisms, but I haven't played with them enough to be able 
to give you any details about that.

/dps

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


[web2py] Re: Putting time in a string

2015-11-04 Thread Dave S


On Wednesday, November 4, 2015 at 7:13:16 AM UTC-8, Garry Smith wrote:
>
> Hi
> Thanks for the reply, the session.time was left in my mistake, 
> I tried it without the session and it still gave me the same error, I have 
> tried your suggestion and is working.
> The only problem I am having know is the request.client is sending a ip of 
> 127.0.0.1, which ever client pc I use.
> This is only being used on a intranet and should pick up a 10.1.2.* as the 
> ip.
>
>>
>>
127.0.0.1 is localhost, and if you're testing this code from a browser 
running on the machine that  runs web2py, that's what you'd expect.  If 
your browser is on a different machine, then I can't explain it without 
seeing more details.  You might be able to use the debugging toolbar to see 
what you've got in your view:

{{=response.toolbar()}}


http://web2py.com/books/default/chapter/29/03/overview#Debugging-toolbar>


I am quite fond, by the way, of using the CAT() helper when my controller is 
building up a string from pieces of "stuff".


HTH


/dps





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


[web2py] Re: decorator "Or" operator syntax

2015-11-04 Thread Alex Glaros
oops, regarding security, you're right Anthony. Users could walk the URL 
address. Is this better? Seems to work...

@auth.requires(lambda: not db((db.auth_membership.user_id == auth.user_id) 
& (db.auth_membership.group_id == db.auth_group.id) & (db.auth_group.role 
== request.get_vars.specificObjectID) & (db.auth_group.organizationID == 
request.get_vars.specificOrganizationID)).isempty())

regarding "or" operator, you are correct, I used the wrong logic to build 
the records. OR works.

Thanks so much for catching these errors. It's really appreciated,

Alex

-- 
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: decorator "Or" operator syntax

2015-11-04 Thread Anthony


On Wednesday, November 4, 2015 at 5:47:07 PM UTC-5, Alex Glaros wrote:
>
> oops, regarding security, you're right Anthony. Users could walk the URL 
> address. Is this better? Seems to work...
>
> @auth.requires(lambda: not db((db.auth_membership.user_id == auth.user_id) 
> & (db.auth_membership.group_id == db.auth_group.id) & (db.auth_group.role 
> == request.get_vars.specificObjectID) & (db.auth_group.organizationID == 
> request.get_vars.specificOrganizationID)).isempty())
>

I don't know on what basis you are trying to restrict access. Based on the 
above, someone could still construct a URL that includes any 
auth_group.role that they know they belong to. If you're OK with that, then 
that's fine, but it is equivalent to allowing access to anyone who has any 
Auth role whatsoever. In general, it seems odd to determine which roles are 
allowed access based on roles sent as user input.

Anthony

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


Re: [web2py] its possible get mac address?

2015-11-04 Thread Dave S

On Wednesday, November 4, 2015 at 11:58:07 AM UTC-8, Carlos Cesar Caballero 
wrote:
 

> El 04/11/15 a las 14:30, Fabiano Almeida escribió:
>
> Hi! 
>
> Web2py can obtain mac address from user?
>
> > Bassicly, the MAC address don't cross the routers, so, you can't get the 
mac address of a client from a external network server, 
> you only can get the MAC of the last router. You could do some tweak 
using ARP, but only if the client and server are in the same subnet.
 
  Web2py does give you access to the requesting IP.  This my be a NAT'd 
value if the client is on an internal network, which is mostly the case.

/dps

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


[web2py] Re: decorator "Or" operator syntax

2015-11-04 Thread Alex Glaros
That's completely unacceptable, bad security. You are right Anthony. What 
would be a better method?

Right now the value of role field in db.auth_group is the same as the 
primary key of the object I want to set auth for.  I was hoping to use that 
idea to be able to restrict users to that organization's records only, 

Can I keep that concept and add something else to improve security? 

thanks

Alex

-- 
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] auth_group/membership auto assign and disable sign up?

2015-11-04 Thread lucas
hello one and all,

i set up three records under auth_group, Developer, Administrator, and 
Personnel.  a few questions.  i want to disable the "Sign Up" option under 
the "Log In" submenu.  how do i remove that option?  

and i want anyone with Administrator right to be able to create new login 
users.  in which case, when he does, how do i direct web2py code to default 
the new login to assign that new member, under auth_member to the group_id 
of 3, which is Personnel?

thank you in advance, lucas

-- 
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: auth_group/membership auto assign and disable sign up?

2015-11-04 Thread 黄祥
i want to disable the "Sign Up" option under the "Log In" submenu.  how do 
i remove that option?
*models/db.py*
auth.settings.actions_disabled = myconf.take('auth.actions_disabled')

*static/appconfig.ini*
actions_disabled   = ['register']

how do i direct web2py code to default the new login to assign that new 
member, under auth_member to the group_id of 3, which is Personnel?
*models/db.py*
auth.settings.create_user_groups = False
auth.settings.everybody_group_id = myconf.take('auth.everybody_group_id')

*static/appconfig.ini*
everybody_group_id = 3

best regards,
stifan

-- 
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: auth_group/membership auto assign and disable sign up?

2015-11-04 Thread Dave S
On Wednesday, November 4, 2015 at 7:23:38 PM UTC-8, lucas wrote:
>
> hello one and all,
>
> i set up three records under auth_group, Developer, Administrator, and 
> Personnel.  a few questions.  i want to disable the "Sign Up" option under 
> the "Log In" submenu.  how do i remove that option?  
>
> and i want anyone with Administrator right to be able to create new login 
> users.  in which case, when he does, how do i direct web2py code to default 
> the new login to assign that new member, under auth_member to the group_id 
> of 3, which is Personnel?
>
>  
If the Administrator member is filling in a form, you should be able to 
specify a default for the field.  Or set the default in the table 
definition, and make it writable=false in the form.  Use Appadmin to 
upgrade anyone.

/dps

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


[web2py] Re: auth_group/membership auto assign and disable sign up?

2015-11-04 Thread lucas
i don't understand the myconf.take function.   can you explain that?  is it 
new to web2py?  lucas

-- 
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: auth_group/membership auto assign and disable sign up?

2015-11-04 Thread 黄祥
oopss, sorry, my bad.
the recent web2py version is adapted appconfig to store configuration like 
(db uri, smtp server n login, form styling, auth config like my example, 
meta, etc), you can see it in models/db.py
e.g.
*models/db.py*
from gluon.contrib.appconfig import AppConfig
## once in production, remove reload=True to gain full speed
myconf = AppConfig(reload = True)

so, the example i gave you before is return an error if you didn't define 
myconf

best regards,
stifan


On Thursday, November 5, 2015 at 11:19:34 AM UTC+7, lucas wrote:
>
> i don't understand the myconf.take function.   can you explain that?  is 
> it new to web2py?  lucas
>
>

-- 
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: auth_group/membership auto assign and disable sign up?

2015-11-04 Thread lucas
oh, ok, yes, a config file, i get it.  nice.  i might use that new feature 
now.  thank you for that.  lucas

On Wednesday, November 4, 2015 at 11:26:40 PM UTC-5, 黄祥 wrote:
>
> oopss, sorry, my bad.
> the recent web2py version is adapted appconfig to store configuration like 
> (db uri, smtp server n login, form styling, auth config like my example, 
> meta, etc), you can see it in models/db.py
> e.g.
> *models/db.py*
> from gluon.contrib.appconfig import AppConfig
> ## once in production, remove reload=True to gain full speed
> myconf = AppConfig(reload = True)
>
> so, the example i gave you before is return an error if you didn't define 
> myconf
>
> best regards,
> stifan
>
>
> On Thursday, November 5, 2015 at 11:19:34 AM UTC+7, lucas wrote:
>>
>> i don't understand the myconf.take function.   can you explain that?  is 
>> it new to web2py?  lucas
>>
>>

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


[web2py] Web2py / Pydal Time Fields

2015-11-04 Thread Mark Graves
Hey everyone,

I find myself in the need for microsecond level precision for time fields 
where I am querying over those fields regularly.

As I dug into pydal and web2py's internals, I noticed that it seems to be 
convention that times are truncated to H:M:S

I'm aware I can easily store as a string and coerce or define a custom 
field type or store as a datetime for the required precision.

I'm finding that rather cumbersome.

Am I missing something or would this be the best way to approach this?

-Mark

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