[web2py] Re: web2py dashboard external data

2014-04-07 Thread Dave S
On Monday, April 7, 2014 3:57:12 PM UTC-7, Trent Telfer wrote:
>
> Just in case someone might find this useful I was download Bank of Canada 
> FX information and scrubbing the information for injection into a database 
> with DAL. See code below:
>
>
Cool!  Thanks for sharing!

/dps

 

> import csv
> import requests
> import datetime as dt
> from datetime import timedelta
> from datetime import datetime
> import os
> import sys
> from itertools import izip_longest
> #import web2py DAL
> from gluon.sql import DAL, Field
> from gluon.validators import *
> import pprint
>
>
> # CSVFile : This is the name of the file on disk to store the newly 
> produced
> # csv file.
> CSVFile = 'temp.csv'
>
>
> def main():
> # The protocol and full path to our database file.
> db = DAL('sqlite://pricing_db.sqlite', 
> folder='D:\Anaconda\envs\web2py\web2py\database')
>
> # Define the table, note that the field "id" is automatic.
> db.define_table('cad_fx',
> Field('date', 'datetime'),
> Field('usd', 'double'),
> Field('convrate', 'double'),
> Field('recrate', 'double'))
>
> # Set date information
> t = dt.date.today()
> startDate = (t - timedelta(days=0)).strftime("%Y-%m-%d")
> endDate = t.strftime("%Y-%m-%d")
> tenDate = (t - timedelta(days=(365*10))).strftime("%Y-%m-%d")
>
> # Call string composition function
> s = BOCFX_url_string(tenDate, startDate, endDate)
>
> # Call download file function
> get_File(s, CSVFile)
>
> # Remove string from list
> string_to_remove = 'Bank holiday'
> price_list = format_list(CSVFile, string_to_remove)
>
> for item in price_list:
> 
> db.cad_fx.update_or_insert(date=datetime.strptime(item[0],'%Y-%m-%d'),
>  usd=float(item[1]),
>  convrate=float(item[2]),
>  recrate=float(item[3]))
> db.commit()
>
>
> def BOCFX_url_string(tDate, fDate, lDate):
> """Returns an http string composed of the start date [fDate], the end 
> date [lDate]
> and the ten month prior date from the start date [tDate] for 
> downloading the
> Bank of Canada USD foreign exchange rate.
>
> INPUT:
> tDate = Date ten years back from start date.
> fDate =
> """
> BOCFX_string = ('
> http://www.bankofcanada.ca/stats/results/csv?sF=LOOKUPS_CAD' +
> '&lP=lookup_currency_converter.php&sR={0}&sTF=to&sT=_0101&co=1.00&dF=' 
> +
> '{1}&dT={2}'
> ).format(tDate, fDate, lDate)
> return(BOCFX_string)
>
>
> def get_File(urls, write_file):
> """Takes http url string to a file and file location and writes to 
> disk.
> """
> try:
> f = requests.get(urls, allow_redirects=True)
> with open(write_file, 'wb') as xfile:
> for chunk in f.iter_content():
> xfile.write(chunk)
> except requests.exceptions.RequestException as e:
> print e
> sys.exit(1)
>
>
> def format_list(write_file, s):
> # Open CSV file and input into a list of tuples
> with open(write_file, 'Ur') as f:
> data = list(tuple(rec) for rec in csv.reader(f, delimiter=','))
>
> # Removes unwanted empty elements
> data = [list(x for x in y if x) for y in data]
>
> # Remove unwanted rows
> data.pop(0)
> data.pop(0)
> header = data.pop(0)
> data.pop()
>
> data.reverse()
> #data.insert(0, header)
>
> # Remove bank holidays
> d = list()
> for item in data:
> for subitem in item:
> if subitem == s:
> d.append(data.index(item))
> break
>
> data = [i for j, i in enumerate(data) if j not in d]
>
> return(data)
>
>
> if __name__ == '__main__':
> main()
>

-- 
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 dashboard external data

2014-04-07 Thread Trent Telfer
Just in case someone might find this useful I was download Bank of Canada 
FX information and scrubbing the information for injection into a database 
with DAL. See code below:

import csv
import requests
import datetime as dt
from datetime import timedelta
from datetime import datetime
import os
import sys
from itertools import izip_longest
#import web2py DAL
from gluon.sql import DAL, Field
from gluon.validators import *
import pprint


# CSVFile : This is the name of the file on disk to store the newly produced
# csv file.
CSVFile = 'temp.csv'


def main():
# The protocol and full path to our database file.
db = DAL('sqlite://pricing_db.sqlite', 
folder='D:\Anaconda\envs\web2py\web2py\database')

# Define the table, note that the field "id" is automatic.
db.define_table('cad_fx',
Field('date', 'datetime'),
Field('usd', 'double'),
Field('convrate', 'double'),
Field('recrate', 'double'))

# Set date information
t = dt.date.today()
startDate = (t - timedelta(days=0)).strftime("%Y-%m-%d")
endDate = t.strftime("%Y-%m-%d")
tenDate = (t - timedelta(days=(365*10))).strftime("%Y-%m-%d")

# Call string composition function
s = BOCFX_url_string(tenDate, startDate, endDate)

# Call download file function
get_File(s, CSVFile)

# Remove string from list
string_to_remove = 'Bank holiday'
price_list = format_list(CSVFile, string_to_remove)

for item in price_list:

db.cad_fx.update_or_insert(date=datetime.strptime(item[0],'%Y-%m-%d'),
 usd=float(item[1]),
 convrate=float(item[2]),
 recrate=float(item[3]))
db.commit()


def BOCFX_url_string(tDate, fDate, lDate):
"""Returns an http string composed of the start date [fDate], the end 
date [lDate]
and the ten month prior date from the start date [tDate] for 
downloading the
Bank of Canada USD foreign exchange rate.

INPUT:
tDate = Date ten years back from start date.
fDate =
"""
BOCFX_string = 
('http://www.bankofcanada.ca/stats/results/csv?sF=LOOKUPS_CAD' +
'&lP=lookup_currency_converter.php&sR={0}&sTF=to&sT=_0101&co=1.00&dF=' +
'{1}&dT={2}'
).format(tDate, fDate, lDate)
return(BOCFX_string)


def get_File(urls, write_file):
"""Takes http url string to a file and file location and writes to disk.
"""
try:
f = requests.get(urls, allow_redirects=True)
with open(write_file, 'wb') as xfile:
for chunk in f.iter_content():
xfile.write(chunk)
except requests.exceptions.RequestException as e:
print e
sys.exit(1)


def format_list(write_file, s):
# Open CSV file and input into a list of tuples
with open(write_file, 'Ur') as f:
data = list(tuple(rec) for rec in csv.reader(f, delimiter=','))

# Removes unwanted empty elements
data = [list(x for x in y if x) for y in data]

# Remove unwanted rows
data.pop(0)
data.pop(0)
header = data.pop(0)
data.pop()

data.reverse()
#data.insert(0, header)

# Remove bank holidays
d = list()
for item in data:
for subitem in item:
if subitem == s:
d.append(data.index(item))
break

data = [i for j, i in enumerate(data) if j not in d]

return(data)


if __name__ == '__main__':
main()

-- 
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] Best approach to using the DAL with external data sources that will go into multiple tables?

2014-04-07 Thread Trent Telfer
I am attempting to build a small webpage that takes some pricing data from 
a few external sources and displays it on one concise page (a dashboard of 
sorts). My problem is I have 38 timeseries to input in the database and I 
am hoping someone here can suggest a way around writing multiple 
define_tables? All data is in the form of dates with one data point, but 
they don't necessarily all start at the same time.

Thanks,

Trent

-- 
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 change the message 'value already in database or empty' in Register?

2014-04-07 Thread 黄祥
i think you can achieve it using form validation on your controller
e.g.
if form.errors.name:
response.flash = "Sorry chap, that doesn't exist"

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.


Re: [web2py] Smartgrid and archive buttons

2014-04-07 Thread 黄祥
had you already try to define the linked_table explicit in your smartgrid?
e.g.
linked_tables = ['detail']

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: Form data hint

2014-04-07 Thread 黄祥

>
> 1) when the form is accessed some of the fields should already contain a 
> hint which is not necessarily the default value of the field
>

i think you can achieve it using default 
e.g.
table.registration_date.default = request.now
 

> 2) the user should select a value from a drop-down list and some other 
> fields should be filled with other hints (the data used for giving these 
> hints should come from another table)
>

you can achieve it when you have the relation on your table and set the 
IS_IN_DB() validation for the field that reference to another table
e.g.
db.define_table('branch', 
Field('address', 'text'), 
format = '%(address)s')

db.define_table('header', 
Field('branch', 'reference branch'), 
format = '%(branch)s')

db.header.branch.requires = IS_IN_DB(db, db.branch.id, '%(address)s')

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: Why does LINK work and STYLE doesn't?

2014-04-07 Thread Paolo Caruccio
Well, I think that style element with the src attribute in order to link an 
external stylesheet works only in XHTML2. Definitely it does not work when 
html5 doctype is applied and the current welcome app layout is in html5. 
I will open an issue, asking to correct the example in the book.

Il giorno lunedì 7 aprile 2014 02:03:53 UTC+2, scruffy...@gmail.com ha 
scritto:
>
> Hi,
>
> I'm learning web2py and just messing around... 
>
> I have a static file:  css/style.css
>
> It contains:   h1 {color: red;}
>
> When I make a simple view with an h1 block, my stylesheet gets applied if 
> I put:
>{{=LINK(_rel="stylesheet", _type="text/css", _href=URL('static', 
> 'css/style.css'))}}  in my , but not if I put:
>{{=STYLE(_src=URL('static', 'css/style.css'))}} which is similar to the 
> example given  for the STYLE helper in chapter 5 of the web2py manual. 
>  What am I missing?
>
> Thanks,
> Scruffy
>

-- 
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: load file from folder

2014-04-07 Thread Anthony
Something like:

import os
import pandas as pd
data = pd.read_csv(open(os.path.join(request.folder, 'static', 
'path/to/data.csv'), 'r'))

Anthony

On Monday, April 7, 2014 4:49:19 PM UTC-4, ArtDijk wrote:

> I want to do some pandas analysis on a csv. I've manually put the file in 
> the '/static' folder.
> Later I want to show a plot based on the analysis.
> What should be the correct syntax to load the csv file in the default.py ?
> 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] load file from folder

2014-04-07 Thread ArtDijk
I want to do some pandas analysis on a csv. I've manually put the file in 
the '/static' folder.
Later I want to show a plot based on the analysis.
What should be the correct syntax to load the csv file in the default.py ?
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: How do I post an image to web2py from HTML5 Canvas

2014-04-07 Thread pubu
hi,

i would do the follow:

1) in model use compute to create image form base64 string:
db.define_table('user_images',
Field('my_image', 'upload', label=T('My Image'), compute=lambda r: 
create_image_from_base64_str(r.my_image_b64)),
Field('my_image_b64', 'text')
)

def create_image_from_base65_str(r):
...

return filename


2) in controller:

form = SQLFORM(db.user_images)

if form.process().accepted:
#form processed with no errors
#image is created
#make redirect
redirect(URL('xyz', args=[form.vars.id]), client_side=True)   
...

3) in view i would use form.custom to create form with hidden fields and 
fake button. with js i would save the base64 string in the hidden field and 
do form.submit()



Am Montag, 7. April 2014 00:46:11 UTC+2 schrieb Ari Lion BR Sp:
>
> Any answer? I have the very same need. 
>

> Thanks 
> Ari
>
> Em segunda-feira, 2 de dezembro de 2013 14h02min30s UTC-2, Michael Hall 
> escreveu:
>>
>> If I have the following model:
>>
>> db.define_table('user_images',
>> Field('my_image', 'upload',
>>   label=T('My Image')),
>> )
>>
>> and In my rendered html view I have a canvas, the canvas has produced an 
>> image saved in the variable 
>> document.getElementById('canvas').src = dataURL;
>>
>> Underneath the image is an upload button, I wish to POST the canvas image 
>> to user_images.myimage when the button is pressed and then move to a new 
>> view and controller which displays the uploaded image and has some more 
>> editing options.
>>
>> What is the best way to achieve this? Is it possible to render a sqlform 
>> that only has a button which when pressed uploads dataURL and redirects to 
>> the next controller/view?
>>
>>
>>

-- 
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-mini-conference, May 4, 2014

2014-04-07 Thread Francisco Betancourt
Please make more conferences in more locations, maybe next year, I would 
have liked to attend, but it's to far, plus there's no more room. I look 
forward to the videos.

El lunes, 3 de marzo de 2014 09:36:29 UTC-6, Massimo Di Pierro escribió:
>
> We have a date, a location, and a web site:
>
>  http://www.experts4solutions.com/web2py_conference
>
> Please register if you plan to attend.
> The more the merrier. We are looking for sponsors.
>
> Massimo
>

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


[web2py] Re: feedback da default.py a web2py

2014-04-07 Thread Massimo Di Pierro
Si!

Invece di:
ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')
usa:
ajax_page('POST', '{{=URL('AllegaNuovoFile')}}',['txtIdCarico','
pathCompleto'],'target')

and from:

def AllegaNuovoFile():
   ...
   response.flash = "Word done!"
   # or response.js = "jquery code to be executed upon return. ... "
   return dict()

On Monday, 7 April 2014 04:16:47 UTC-5, Carlo DOnofrio wrote:
>
> Salve a tutti,
>
> vorrei sapere se è possibile avere un feedback di fine esecuzione 
> istruzioni della funzione richiamata in default.py. 
>
> Mi spiego meglio. Ho creato tutta una serie di pagine html in cui, per 
> esempio, ho necessità di salvare degli allegati in un database creato in 
> mysql.
>
> All'interno della pagina ho queste istruzioni:
>
> 
> 
> 
>  Allega Nuovo File:
>  
>  onchange="this.form.pathCompleto.value=this.value.substr(12);">
>  
> 
>
>  onclick="ControllaNuovoFile(); 
> ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')"/>
>  
> 
>
>
>
> 
>
>
> Che richimano la funzione AllegaNuovoFile presente in default.py:
>
> def AllegaNuovoFile():
> directory = "C:\Upload\\"
> nomefile = request.vars.pathCompleto
> riferimentoIdCarico= request.vars.txtIdCarico
> if (nomefile <> '') :
> filepercorso = directory + nomefile
> stream = open(filepercorso,'rb')
> db.tabella_files.insert(nome_file=nomefile,dati_file=db.tabella_files.dati_file.store(stream,filepercorso),
>  
> riferimento_id=riferimentoIdCarico,riferimento_tabella="Carico")
> db.commit()
> return dict()
>
>
> C' è un modo per avere un feedback da default.py per avere certezza di 
> esecuzione funzione?
>

-- 
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 change the message 'value already in database or empty' in Register?

2014-04-07 Thread deep jain
hey, is there any way in which i can flash this message (like 
response.flash)?

On Monday, 19 December 2011 06:10:09 UTC+5:30, ニコノコ wrote:
>
> IS_IN_DB(db(db.mytable.id>0), 'mytable.id', db.mytable._format
>
> ,error_message=T("Sorry chap, that doesn't exist"))
>
>
> You may specify your own error_message for any built-in validator.
>
>
> On Sunday, December 11, 2011, Constantine Vasil wrote:
>
>> How to change the message 'value already in database or empty' in 
>> Register?
>>
>> Thanks,
>>
>> Regards,
>> --Constantine
>>
>

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


Re: [web2py] Re: web2py-mini-conference, May 4, 2014

2014-04-07 Thread Frank

On 3 Apr 2014 at 20:58:41, Massimo Di Pierro (massimo.dipie...@gmail.com) wrote:

Registration is closed. We exceeded room capacity. We have sponsors, 
volunteers, talks proposals, and a lot of work ahead of us. It is going to be 
great.
We will do our best to record everything.
‘… record everything’ <- #win #thanks :) 



Massimo

On Monday, 3 March 2014 09:36:29 UTC-6, Massimo Di Pierro wrote:
We have a date, a location, and a web site:

     http://www.experts4solutions.com/web2py_conference

Please register if you plan to attend.
The more the merrier. We are looking for sponsors.

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

-- 
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] Form data hint

2014-04-07 Thread csavorgn
Hi, I'm a web2py newbie and I'm developing my first app.
In my app I have a database containing a table with many fields. I would 
like to create three different forms to add rows to the table.
Each one of these forms should help the user to fill the data corresponding 
to a special situation.
This is the behaviour I would like to achieve:
1) when the form is accessed some of the fields should already contain a 
hint which is not necessarily the default value of the field
2) the user should select a value from a drop-down list and some other 
fields should be filled with other hints (the data used for giving these 
hints should come from another table)
Is it possible to achieve this behaviour? Could you give me some hints?
Thanks!
Carlo

-- 
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: Paypal Recurring Payments? Any experience? Any alternatives?

2014-04-07 Thread Clément Boulais - MangoPay
Hello Everyone,

Here at Mangopay we serve and assist all european based company to process 
there payments through a simple API.
Please check our transparent pricing and dedicated 
website: http://www.mangopay.com/

Also, feel free to contact me for any enquiry: sa...@mangopay.com

All best wishes for your growing businesses,
Clément


Le vendredi 4 avril 2014 21:23:51 UTC+2, Leonel Câmara a écrit :
>
> You can try integrating mangopay. It's a lot cheaper than stripe and works 
> for all the eurozone.
>

-- 
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 does LINK work and STYLE doesn't?

2014-04-07 Thread scruffyexaminer
Hi,

I'm learning web2py and just messing around... 

I have a static file:  css/style.css

It contains:   h1 {color: red;}

When I make a simple view with an h1 block, my stylesheet gets applied if I 
put:
   {{=LINK(_rel="stylesheet", _type="text/css", _href=URL('static', 
'css/style.css'))}}  in my , but not if I put:
   {{=STYLE(_src=URL('static', 'css/style.css'))}} which is similar to the 
example given  for the STYLE helper in chapter 5 of the web2py manual. 
 What am I missing?

Thanks,
Scruffy

-- 
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] feedback da default.py a web2py

2014-04-07 Thread Carlo DOnofrio


Salve a tutti,

vorrei sapere se è possibile avere un feedback di fine esecuzione 
istruzioni della funzione richiamata in default.py. 

Mi spiego meglio. Ho creato tutta una serie di pagine html in cui, per 
esempio, ho necessità di salvare degli allegati in un database creato in 
mysql.

All'interno della pagina ho queste istruzioni:




 Allega Nuovo File:
 

 



 







Che richimano la funzione AllegaNuovoFile presente in default.py:

def AllegaNuovoFile():
directory = "C:\Upload\\"
nomefile = request.vars.pathCompleto
riferimentoIdCarico= request.vars.txtIdCarico
if (nomefile <> '') :
filepercorso = directory + nomefile
stream = open(filepercorso,'rb')
db.tabella_files.insert(nome_file=nomefile,dati_file=db.tabella_files.dati_file.store(stream,filepercorso),
 
riferimento_id=riferimentoIdCarico,riferimento_tabella="Carico")
db.commit()
return dict()


C' è un modo per avere un feedback da default.py per avere certezza di 
esecuzione funzione?

-- 
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] Smartgrid and archive buttons

2014-04-07 Thread Seth J
The problem is that there are no field explicitly defined for that link. 
 It appears automatically when I enable record_versioning. 

On Monday, April 7, 2014 2:49:00 AM UTC-4, Johann Spies wrote:
>
>
>
>
> On 4 April 2014 00:01, Seth J > wrote:
>
> Hi guys,
>>
>>
>> As you can see there's "Work log archives" link before the button.  When 
>> I click on it, it takes me to an archive for that record and they have the 
>> same buttons attached to the right of every 'version'.  How do I disable 
>> all buttons only in an archive table?  Also, is there a way to change the 
>> wording on that link to something different than "Work log archives" in 
>> smartgrid?
>>
>>
> Try adding  label = 'your desired label'  to the field.
>
> Regards
> Johann
>
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

-- 
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: Ckeditor plugin - Update ckeditor

2014-04-07 Thread Marco Mansilla
El Mon, 7 Apr 2014 05:17:31 -0300
Marco Mansilla  escribió:

> El Tue, 25 Mar 2014 16:37:46 -0700 (PDT)
> Tim Richardson  escribió:
> 
> > try this
> > https://github.com/timrichardson/web2py_ckeditor4/releases/download/R-0.3/web2py.plugin.ckeditor.w2p
> > 
> 
> Hi, I'm having a really hard struggle with this, and so far I am
> really sure that is not a ckeditor plugin error, but it is referred
> to.
> 
> I have changed the default template for my app, to one still boostrap
> based, but to version 3, and made chages according to this[0] guide.
> 
> When I set {{extend 'layout.html'}}, everything works well but when a
> change to {{extend 'my-custom-layout.html'}}, seems to be no problem
> but the form elements supposed to have the ckeditor widgets show up as
> regular text widgets.
> 
> Only hint I have is one line in firebug console saying:
> 
>TypeError: jQuery(...).ckeditor is not a function
>   jQuery('#posts_post_content').ckeditor(config);
> 
> The whole script code marked as error is:
> 
> 
> function ckeditor_config() {
> return {
>   contentsCss:
> ['/myapp/static/css/base.css','/myapp/static/plugin_ckeditor/contents.css'],
> filebrowserUploadUrl: '/myapp/plugin_ckeditor/upload',
> filebrowserBrowseUrl: '/myapp/plugin_ckeditor/browse', toolbar: [
>   {name: 'clipboard', items: ['Cut', 'Copy', 'Paste',
> 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']}, {name: 'editing',
> items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker',
> 'Scayt']}, {name: 'links', items: ['Link', 'Unlink', 'Anchor']},
> {name: 'insert', items: ['Image', 'Flash', 'Table', 'SpecialChar']},
> {name: 'tools', items: ['Maximize', 'ShowBlocks', '-', 'Source']},
> '/', {name: 'styles', items: ['Format', 'Font', 'FontSize']},
>   {name: 'basicstyles', items: ['Bold', 'Italic', 'Underline',
> 'Strike', '-', 'RemoveFormat']}, {name: 'paragraph', items:
> ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent',
> 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']}, ],
>   scayt_autoStartup: true,
>   }
>   }
> 
>   jQuery(function() {
>   var config = ckeditor_config();
>   jQuery('#posts_post_content').ckeditor(config); 
>   });
>  
> 
> I guess I'm missing some script to include but not shure which one.
> Jquery, web2py_ajax, and everything else is called in the
> custom-layout file.
> 
> Thanks in advance.
> 
> Marco
> 
> [0]
> http://www.web2pyslices.com/slice/show/1516/adapt-a-css-template-to-web2py-layouthtml
> 

Sorry... never mind... I just needed to call
plugin_ckeditor/adapters/jquery.js 

Marco.

-- 
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] Month picker

2014-04-07 Thread Richard Vézina
I would have the something similar for birth date with no year for user
privacy on their age...

Richard


On Sun, Apr 6, 2014 at 6:24 AM, Pearu Peterson wrote:

> Hi,
>
> In a form I'd like to have a field that contains month and year
> information, only. The current date picker (via using IS_DATE validator,
> for instance) includes also days which for the given application UI would
> be a noise.
>
> Is there any way to configure date pickler to show only months (as an
> array) and years? I found http://jsfiddle.net/kidsysco/JeZap/ which would
> be perfect solution, but I'd like to stay within web2py framework when
> possible.
>
> Thanks,
> Pearu
>
>  --
> 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.


Re: [web2py] Mozilla Persona (Simple, privacy-sensitive single sign-in) and Web2py

2014-04-07 Thread Michele Comitini
+1 definitely

2014-04-07 13:53 GMT+02:00 puercoespin :
> I think Mozilla Persona (http://www.mozilla.org/en-US/persona/) may be an
> interesting  sign in technology in web2py.
>
> There are lot of plugins for python frameworks, in
> https://developer.mozilla.org/en-US/Persona/Libraries_and_plugins,
>
> may be an web2py plugin would be interesting. What do you think?
>
>
>
> --
> 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] Mozilla Persona (Simple, privacy-sensitive single sign-in) and Web2py

2014-04-07 Thread puercoespin
I think Mozilla Persona (http://www.mozilla.org/en-US/persona/) may be an 
interesting  sign in technology in web2py.

There are lot of plugins for python frameworks, 
in https://developer.mozilla.org/en-US/Persona/Libraries_and_plugins,

may be an web2py plugin would be interesting. What do you think?

 

-- 
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: how to embed a d3.js script in a view correctly?

2014-04-07 Thread António Ramos
After all the pain learning d3 and angular i discovered d3js directives for
angular.

using them inside web2py is easy

check one of them here about the line chart
http://cmaurer.github.io/angularjs-nvd3-directives/line.chart.html


2014-04-05 20:11 GMT+01:00 Martina Gruber :

> Hi Sihui,
>
> Just add a div with an id after extend layout and then select this id from
> d3.
> If you select "body" and append a circle it will go at the bottom of the
> page.
>
> {{response.files.append(URL(r=request,c='static',f='/js/d3.js'))}}
>> {{extend 'layout.html'}}
>>
>>  
>>
>> 
>>  d3.select('#mychart').append('svg').append('circle').style("stroke",
>> "gray").style("fill", "red").attr("r", 40).attr("cx", 50).attr("cy", 50);
>> 
>>
>>  --
> 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.


Re: [web2py] Re: How do I "SELECT * FROM table WHERE field IN (1,2,3,4,7)

2014-04-07 Thread Michele Comitini
In PHP you post SQL queries as strings to the DB backend.
If you want you can do that like:

db.executesql("SELECT * FROM table WHERE field IN (1,2,3,4,7) AND
field2='3'") but you loose much of the benefits of using DAL, for
instance query portability.

mic

2014-04-07 4:20 GMT+02:00 Cliff Kachinske :
> Kurt,
>
> I think the key is to realize that the WHERE clause comes first in DAL
> dialect, and the fields to be selected come after.
>
> On Saturday, April 5, 2014 11:49:28 PM UTC-4, Kurt Jensen wrote:
>>
>> How do I do :
>>
>> "SELECT * FROM table WHERE field IN (1,2,3,4,7) AND field2='3'""
>>
>> AND / OR
>>
>> "DELETE FROM table WHERE field1 IN (1,2,3,4,7) AND field2='3'"
>>
>> in web2py DAL?
>>
>> I come from PHP and I am really struggling with DAL in 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+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: Ckeditor plugin - Update ckeditor

2014-04-07 Thread Marco Mansilla
El Tue, 25 Mar 2014 16:37:46 -0700 (PDT)
Tim Richardson  escribió:

> try this
> https://github.com/timrichardson/web2py_ckeditor4/releases/download/R-0.3/web2py.plugin.ckeditor.w2p
> 

Hi, I'm having a really hard struggle with this, and so far I am really
sure that is not a ckeditor plugin error, but it is referred to.

I have changed the default template for my app, to one still boostrap
based, but to version 3, and made chages according to this[0] guide.

When I set {{extend 'layout.html'}}, everything works well but when a
change to {{extend 'my-custom-layout.html'}}, seems to be no problem
but the form elements supposed to have the ckeditor widgets show up as
regular text widgets.

Only hint I have is one line in firebug console saying:

   TypeError: jQuery(...).ckeditor is not a function
jQuery('#posts_post_content').ckeditor(config);

The whole script code marked as error is:


function ckeditor_config() {
return {
contentsCss:
['/myapp/static/css/base.css','/myapp/static/plugin_ckeditor/contents.css'],
filebrowserUploadUrl: '/myapp/plugin_ckeditor/upload',
filebrowserBrowseUrl: '/myapp/plugin_ckeditor/browse', toolbar: [
{name: 'clipboard', items: ['Cut', 'Copy', 'Paste',
'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo']}, {name: 'editing',
items: ['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker',
'Scayt']}, {name: 'links', items: ['Link', 'Unlink', 'Anchor']}, {name:
'insert', items: ['Image', 'Flash', 'Table', 'SpecialChar']}, {name:
'tools', items: ['Maximize', 'ShowBlocks', '-', 'Source']}, '/',
{name: 'styles', items: ['Format', 'Font', 'FontSize']},
{name: 'basicstyles', items: ['Bold', 'Italic', 'Underline',
'Strike', '-', 'RemoveFormat']}, {name: 'paragraph', items:
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent',
'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']}, ],
scayt_autoStartup: true,
}
}

jQuery(function() {
var config = ckeditor_config();
jQuery('#posts_post_content').ckeditor(config); 
});
 

I guess I'm missing some script to include but not shure which one.
Jquery, web2py_ajax, and everything else is called in the custom-layout
file.

Thanks in advance.

Marco

[0]
http://www.web2pyslices.com/slice/show/1516/adapt-a-css-template-to-web2py-layouthtml

-- 
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] Use IS_MATCH for optional form entry

2014-04-07 Thread chris_g
Thank you Johann, that worked for me.

On Monday, April 7, 2014 4:52:34 PM UTC+10, Johann Spies wrote:
>
> On 7 April 2014 08:21, chris_g > wrote:
>
>
>> How do I use IS_MATCH for field validation if the field only contains 
>> data?
>>
>> This works for me:
>> IS_MATCH('^\d{10}', extract=True, error_message='Telephone number should 
>> have 10 digits.')
>>
>> so long as a 10 digit number is required.
>>
>> But what if I a want to make it acceptable to enter a 10 digit number or 
>> leave the field blank?
>>
>> Is there a way to make the IS_MATCH validator checked only if a non-empty 
>> string has been passed to the FORM for that field?
>>
>
> What about IS_EMPTY_OR(IS_MATCH('^\d{10}', extract=True, 
> error_message='Telephone number should have 10 digits.')) ?
>
> Regards
> Johann
> -- 
> Because experiencing your loyal love is better than life itself, 
> my lips will praise you.  (Psalm 63:3)
>  

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