[web2py] sending email

2015-06-21 Thread Chaitu P
Hello all,
Iam the beginner of  web2py.
Iam trying to send email using web2py. Iam following the we2py 
book http://web2py.com/books/default/chapter/34/08/email-and-sms.
Can any one please please let me know what exactly need to do.

-- 
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: Question on DAL Field, unique tuple of fields possible ?

2015-06-21 Thread nikalstudiogames
Hello Massimo,

Thanks for the reply (and also for the YouTube videos on web2py - the first 
one is an awesome introduction to the framework)

Basically, on what I'm trying to do, the user will never input a form.
He will upload a file, which I'll parse and I'll create the form from it.

Maybe I can somehow add the "uniqueness" logic in there by checking first 
in the db if such data is already present or not, rather than a "requires" 
rule in the db model.

Not sure what's best.


Thanks,
  NiKAL

Le jeudi 18 juin 2015 14:19:58 UTC+2, Massimo Di Pierro a écrit :
>
> There is a conceptual problem. You can specify the constraint using SQL 
> but when you input a form, how should the error be reported?
>
> The standard practice is to attach a validator to only one of the two 
> fields
>
> db.define_table('x', Field('a'),Field('b'),...)
> db.x.b.requires = IS_NOT_IN_DB(db(db.x.a==request.vars.a), db.b)
>
>
> On Thursday, 18 June 2015 06:25:07 UTC-5, nikalstu...@gmail.com 
>  wrote:
>>
>> Hello,
>>
>> I'm hoping it's not a too stupid question as I'm new to web2py.
>>
>> I have a table which I fill with data about some games.
>> Each game has an id but multiple players can possibly have played the 
>> same game.
>>
>> So I basically need to have the (game_id, player_id) couple to be unique, 
>> but not each of them separately (one user can play multiple games, and same 
>> game can be used for multiple users).
>>
>> Is there a way to specify that ?
>>
>> My table is currently like :
>> db.define_table("table",
>> Field("game_id"),
>> Field("user_id", 'reference auth_user', 
>> default=auth.user_id),
>> Field("player_name"),
>> Field("start_date", type="datetime"),
>> Field("duration_sec", type="integer"),
>> Field("finish_place", type="integer"),
>>)
>>
>> Thanks in advance,
>>   NiKAL
>>
>

-- 
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] HOWTO: Submit form using Ractive

2015-06-21 Thread M.C. Botha
How do I get the FORM rendered by Ractive to submit?

*CONTROLLER*
def get_form():
try:
user = db.auth_user(auth.user.id)
fields = ['first_name', 'last_name', 'gender', 'email', 'phone']
rslt = SQLFORM(db.auth_user, user, fields=fields, showid=False, 
formname='auth_form', formstyle='bootstrap')
except Exception, e:
print(e.message)

x = request.vars.formname
if rslt.process(session=None, formname='auth_form', keepvalues=True).
accepted:
rslt = 'Accepted'
elif rslt.errors:
rslt = 'Errors'

return dict(auth_form=XML(rslt.xml()))

@auth.requires_login()
def index2():
return dict()

def component_page():
return dict()


*VIEW*
{{extend 'layout.dash.html'}}
{{=LOAD('test_ractivejs','component_page.load',ajax=True)}}

*COMPONENT*


[[[form_xml]]]



var ractive = new Ractive({
delimiters: [ '[[', ']]' ],
tripleDelimiters: [ '[[[', ']]]' ],
el: '#container',
template: '#template',
data: {
form_xml: ''
}
});

function loadForm() {
$.post('{{=URL("get_form")}}', {}, function (data) {
ractive.set({form_xml: data});
});
}

$(function () {
loadForm();
});



-- 
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_api_56_ractive_01_sml.7z
Description: application/7z-compressed


[web2py] how to disable the form.

2015-06-21 Thread Chaitu P
Is there any way that I can disable complete form instead of each 
element.Because I want to have the same format in both the cases.
Here is my code of view...

{{=question.body}}

{{if datetime.timedelta(days=2)>(t-question.created_on):}}
{{=form}}
{{else:}}

Name  
Email 


{{pass}}

-- 
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] Multi file upload

2015-06-21 Thread Chaitu P
Hello,,

I want implement a functionality where by clicking button user should be 
able to upload as many files as he wants. And these should be saved in 
database as well.
User should be able delete those uploads as well.
Can any one please let me know how to implement this.

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


[web2py] Compile and run c program

2015-06-21 Thread Chaitu P
Hello all,
Iam creating a web application using web2py where teacher can post questions 
and students can submit the solution .c file. Now my application should run 
that file.
can anyone suggest me how to priceed with compilation?

-- 
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] How to create concatenated field using date field year() and month() and group by that concatenated field

2015-06-21 Thread Mario Blataric
Hi, 

I have following table definition:

b.define_table('exchange_rate',
Field('currency', length=5, required=True, notnull=True, 
label='Valuta'),
Field('rate_date', type='date', required=True, notnull=True, 
label='Datum tečaja'),
Field('buy_rate', type='decimal(18,6)', required=True, 
notnull=True, label='Kupovni tečaj'),
Field('median_rate', type='decimal(18,6)', required=True, 
notnull=True, label='Srednji tečaj'),
Field('sell_rate', type='decimal(18,6)', required=True, 
notnull=True, label='Prodajni tečaj'))


What I want is to produce "-mm" field from rate_date and then group 
data by that field. 

My query should be like this (a non working example, but to give you an 
idea what I need):

exchangeData = db().select(
db.exchange_rate.currency,
str(db.exchange_rate.rate_date.year()) + "-" + 
str(db.exchange_rate.rate_date.month()),
db.exchange_rate.kupovni_tecaj.avg().with_alias('buy_rate_avg'),
db.exchange_rate.prodajni_tecaj.avg().with_alias('sell_rate_avg'),
orderby=db.exchange_rate.valuta|db.tecajna_lista.datum_tecaja,

groupby=db.exchange_rate.valuta|db.tecajna_lista.db.exchange_rate.rate_date.year()|db.exchange_rate.rate_date.month())


I also tried creating calculated field like this:

Field('year_month', length=20, compute=lambda r: 
'{0:s}-{1:s}'.format(str(r['rate_date'].year()), str(r['rate_date'].month(


But, when I try to read year_now - it is always None (I always truncate and 
insert rows, so calculated field should be calculated). 

Any ideas how to solve this?

Thanks, 
Mario

-- 
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: Encrypt uploaded files

2015-06-21 Thread Gaurav Vichare
openssl command is available on production server. I also tried Pycrypto 
for encryption/decryption. Implementation of encryption/decryption function 
can be anything, that's not my issue. I want suggestions on general 
approach/ flow , 'how to store file in encrypted format and decrypt  while 
downloading?'
On Thursday, June 18, 2015 at 5:26:14 PM UTC+5:30, Mandar Vaze wrote:
>
>  
>
>> command = "openssl enc -aes-256-cbc -salt -in %s -out %s -k %s" % 
>> (input_file, output_file, key)
>>
>
> Will openssl command be available where you want to deploy this ? (on 
> production server)
> What about path of openssl command on the production server ?
>
> Have you considered using encryption libraries like Pycrypto/MCrypto (also 
> pyopenssl)
> Using these libraries should alleviate the dependency on openssl binary 
> (and path issues)
>
> -Mandar
>
>

-- 
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: remove registration link in auth login page

2015-06-21 Thread pmesteves
Why complicate?

Read the book :)

# disable register login (models/db.py) #
auth.settings.actions_disabled.append('register')



quarta-feira, 2 de Junho de 2010 às 16:59:15 UTC, hamdy.a.farag escreveu:
>
> sure !! 
> you'll have to make a small modification in controller default/user 
>
> def user(): 
> form = auth() 
> if request.args(0) == 'register': 
> session.flash = 'Registration disabled' 
> redirect(URL(r=request, c='default', f='index')) 
> return dict(form=form) 
>
> On Jun 2, 7:03 pm, Jason Brower  wrote: 
> > Actually... Could you just do a redirect if they are not logged in? 
> > Br 
> > jason 
> > 
> > 
> > 
> > - Original message - 
> > 
> > > Don't forget to disable registration altogether, otherwise a user can 
> > > use /default/user/register link to add himself and thus may have 
> > > access to things you don't want him to 
> > 
> > > add the line: 
> > > auth.settings.actions_disabled.append('register') 
> > > in your model

-- 
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 start up error

2015-06-21 Thread Pierre
Hi,

I reinstalled firefox on a ubuntu system and since then get  errors:

a list of  
   xdg-open web-browser-name not found
and finally a
  no method available for opening http://127.0.0.1:8000/

howewer $xdg-settings get default-web-browser  issues

userapp-Firefox-VNWX0X.desktop

when I close and re-open terminal after errors and do a
xdg-open http://127.0.0.1:8000/ 
i get the the normal web2py user interface

thank you for your help
I enjoy using 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.


[web2py] Re: why i cannot see database administration db.auth_group and so on

2015-06-21 Thread Laurent Lc
i have added
auth.define_tables() now but it does not work but it is always the same 
problem
Thank you for your answer
regards

Le jeudi 18 juin 2015 14:14:56 UTC+2, Massimo Di Pierro a écrit :
>
> Does your model contain
>
> auth.define_tables()
>
> and are you using
>
> http://...//appadmin
>
> ?
>
>
> On Thursday, 18 June 2015 06:25:04 UTC-5, Laurent Lc wrote:
>>
>> sorry i do not understand i follow the overview (the exemple blogs) and 
>> when i want to create the group "manager"  i cannot see database 
>> administration db.auth_grou
>>
>> why ?
>> thank you very much
>>
>

-- 
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 i cannot see database administration db.auth_group and so on

2015-06-21 Thread Laurent Lc
ok i found a bypass. I don't why but i have followed the wizard and now my 
tables appear.
I don't understand .. 
when we create a new app without the wizard sql.log says "you have created 
the tables" and they do not appear ... strange the source code is exactly 
the same ...

Le jeudi 18 juin 2015 13:25:04 UTC+2, Laurent Lc a écrit :
>
> sorry i do not understand i follow the overview (the exemple blogs) and 
> when i want to create the group "manager"  i cannot see database 
> administration db.auth_grou
>
> why ?
> thank you very much
>

-- 
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] Preference between programmaticaly building a page vs in .html view?

2015-06-21 Thread anonymous anonymous
Dear all,

this is my first post as well as my first attempt with web2py. I've read 
through most of the book and have the following question.

Here are a few guidelines I've understood:


   - Each controller/function should have it's own view
   - There are two ways to build up a webpage one is programmatically and 
   one is by modifying the view.

For example I could have a view:


# controller.py


def fun1():

return { 'content' : H1('Hello') + P('this is my first app World') }


def fun2():

return { 'content' : H1('Hello Again') + P('this is the second page') }


and 


views/controller/fun1.html


{{extend layout.html}}

{{=content}}


views/controller/fun2.html


{{extend layout.html}}

{{=content}}


The alternative would be:


# controller.py


def fun1():

return { }


def fun2():

return { }


and views:


views/controller/fun1.html


{{extend layout.html}}

'Hello'

'this is my first app World'


views/controller/fun2.html


{{extend layout.html}}

'Hello Again'

'this is the second page'


What is the difference, which is better practice? In this simple case which 
pattern is it advisable I follow?


Thank you

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


[web2py] Re: Upgrade to 2.11.2 and Admin Interface doesn't render correctly

2015-06-21 Thread DaneW
Thank you everyone for your very helpful responses - it is working 
correctly again! The solution was indeed to clear the browser cache of 
everything in the past. Many thanks.

On Wednesday, 17 June 2015 07:57:42 UTC+1, DaneW wrote:
>
> I've just upgraded to 2.11.2 and my application works ok but the Admin 
> Interface looks horrible - probably not picking up the right css etc. I 
> tried the Upgrade button but got a DAL error message so then I downloaded 
> the current source file, unzipped it and reinstalled my application files 
> from a backup.
>
> The /admin files are all dated 2015-05-30 but the unrendered Admin page 
> seems to think that it is still on version 2.9.12 and when I look at the 
> page source it says things like src="
> /admin/static/_2.9.12/_2.9.12/js/web2py.js 
> ".
>  
>
>
> I'm hosted on PythonAnywhere. The Admin Interface worked ok before and I 
> don't think I have changed anything else. I've tried using the PA static 
> files facility but it didn't seem to make any difference.
>
>

-- 
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] using PDF.js

2015-06-21 Thread marco


with web2py, if I have a blob field defined as follows:

.

Field('pdf','upload', uploadfield='pdf_file'), 

Field('pdf_file', 'blob')

.

How could I use PDF.js (https://github.com/mozilla/pdf.js/) to display the 
file?

-- 
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: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: ordinal not in range(128)

2015-06-21 Thread Massimo Di Pierro
I think we should remove pg8000 unless this unicode problem is fixed. It 
just causes problem to new pgsql users. psycopg2 is solid.

On Thursday, 18 June 2015 12:59:44 UTC-5, Paolo Valleri wrote:
>
> In general the best choice is psycopg2 however, the issue with pg8000 has 
> been fixed
> I've written an initial basic unittest 
> https://github.com/web2py/pydal/blob/master/tests/base.py#L72 to check 
> possible issues with unicode
>
>
>  Paolo
>
> 2015-06-18 19:47 GMT+02:00 Antonio Salazar :
>
>> Is it still recommended to use psycopg2 instead of pg8000 after this fix?
>>
>> El lunes, 15 de junio de 2015, 5:28:09 (UTC-5), Paolo Valleri escribió:
>>
>>> According to my tests, the current PG adapter works only with psycopg2 
>>> and python2.7
>>> It is broken with both pg8000 and psycopg2 on python 3.x
>>>
>>> A possible fix for pg8000 and python2.7 is here 
>>> https://github.com/ilvalle/pydal/commit/d5450938ae606a3e85deffa831899a35146f5e64
>>>
>>> I've posted an issue for psycopg2 with python3.x here 
>>> https://github.com/psycopg/psycopg2/issues/331#issuecomment-111909256
>>>
>>> Paolo
>>>
>>> On Saturday, June 13, 2015 at 5:22:07 AM UTC+2, Massimo Di Pierro wrote:

 It is a bug in pg8000. You need to install psycopg2

 On Friday, 12 June 2015 13:51:55 UTC-5, Antonio Salazar wrote:
>
> I have the same problem. PostgreSQL database, web2py 
> 2.11.2-stable+timestamp.2015.05.30.16.33.24 
> source install.
>
> Now any field update which has non-ASCII characters fails with " 'exceptions.UnicodeDecodeError'> 'ascii' codec can't decode byte 0xc3 in 
> position X: ordinal not in range(128)"
> By any field update, I mean custom forms, form grids, and even 
> database administration.
>
> This is the traceback after failing to change a user's name to "José" 
> with database administration:
>
> Traceback (most recent call last):
>   File "S:\Extranet\Website\Fuentes\web2py\gluon\restricted.py", line 
> 227, in restricted
> exec ccode in environment
>   File 
> "S:/Extranet/Website/Fuentes/web2py/applications/extranet/controllers/appadmin.py"
>  , 
> line 704, in 
>   File "S:\Extranet\Website\Fuentes\web2py\gluon\globals.py", line 412, 
> in 
> self._caller = lambda f: f()
>   File 
> "S:/Extranet/Website/Fuentes/web2py/applications/extranet/controllers/appadmin.py"
>  , 
> line 343, in update
> if form.accepts(request.vars, session):
>   File "S:\Extranet\Website\Fuentes\web2py\gluon\sqlhtml.py", line 1686, 
> in accepts
> self.id_field_name]).update(**fields)
>   File 
> "S:\Extranet\Website\Fuentes\web2py\gluon\packages\dal\pydal\objects.py", 
> line 2020, in update
> ret = db._adapter.update("%s" % table._tablename,self.query,fields)
>   File 
> "S:\Extranet\Website\Fuentes\web2py\gluon\packages\dal\pydal\adapters\base.py",
>  line 996, in update
> raise e
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 57: 
> ordinal not in range(128)
>
>
> I don't recall having this problem with pre 2.10 versions
>
  -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/AE6NVmLPCwk/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> web2py+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


[web2py] Re: Question on DAL Field, unique tuple of fields possible ?

2015-06-21 Thread 黄祥
already had try unique = True in your define table? btw, why not use 
requires = IS_NOT_IN_DB() validator?

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: how to disable the form.

2015-06-21 Thread 黄祥
just an idea, why not use components? 
e.g.
pseudo code
if true:
load component that have form
else:
don't load component that have form

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: sending email

2015-06-21 Thread 黄祥
please read the book, with ascending order.
1. setting up email (normally in models/db.py)
2. sending email (can be put in models, controllers or modules)

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: Compile and run c program

2015-06-21 Thread 黄祥
i think you can use python subprocess module
e.g. (change the *.exe file with your *.c file)
*controlelrs/default.py*
import subprocess

def change_hostname():
command = "applications/administrator/static/script/windows/change 
hostname.exe"
proc = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = 
subprocess.PIPE)
output, err = proc.communicate()
return locals()

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: Preference between programmaticaly building a page vs in .html view?

2015-06-21 Thread 黄祥
if you just do the print, i think it's better to do it in views, but when 
you have query to database, computing process or another process, i think 
it's better to do it in controllers, and then pass the variable to the view 
to show it in html browser.

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: Encrypt uploaded files

2015-06-21 Thread 黄祥
please take a look at this slice
http://www.web2pyslices.com/slice/show/2012/encrypt-information-into-the-database

not sure is it suitable for your requirement or not

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] Re: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1145: ordinal not in range(128)

2015-06-21 Thread 黄祥
+1

-- 
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: Multi file upload

2015-06-21 Thread 黄祥
please take a look at this discussion :
https://groups.google.com/forum/#!searchin/web2py/multi$20file$20upload/web2py/twIYixbPeZI/E0j9FX6pPsEJ

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: Compile and run c program

2015-06-21 Thread Ron Chatterjee
Alternatively, you can use numpy to run C from python using source version 
of web2py.

https://scipy-lectures.github.io/advanced/interfacing_with_c/interfacing_with_c.html

Check out numpy support 2.8.2.2
2On Sunday, June 21, 2015 at 1:03:04 PM UTC-4, 黄祥 wrote:
>
> i think you can use python subprocess module
> e.g. (change the *.exe file with your *.c file)
> *controlelrs/default.py*
> import subprocess
>
> def change_hostname():
> command = "applications/administrator/static/script/windows/change 
> hostname.exe"
> proc = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = 
> subprocess.PIPE)
> output, err = proc.communicate()
> return locals()
>
> 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: Preference between programmaticaly building a page vs in .html view?

2015-06-21 Thread Anthony
If it is fixed content, use the second pattern (though note that in HTML, 
you do not enclose text in quotes as you have). If you need to generate the 
content dynamically, just pass the data from the controller to the view, 
build the HTML structure in the view, and insert the data where needed. For 
some tips on using the HTML helpers vs. raw HTML in the views, see 
http://stackoverflow.com/questions/8091487/what-are-the-benefits-of-building-html-markup-with-html-helpers-in-web2py/8095585#8095585.

Anthony

On Sunday, June 21, 2015 at 12:13:03 PM UTC-4, anonymous anonymous wrote:
>
> Dear all,
>
> this is my first post as well as my first attempt with web2py. I've read 
> through most of the book and have the following question.
>
> Here are a few guidelines I've understood:
>
>
>- Each controller/function should have it's own view
>- There are two ways to build up a webpage one is programmatically and 
>one is by modifying the view.
>
> For example I could have a view:
>
>
> # controller.py
>
>
> def fun1():
>
> return { 'content' : H1('Hello') + P('this is my first app World') }
>
>
> def fun2():
>
> return { 'content' : H1('Hello Again') + P('this is the second page') }
>
>
> and 
>
>
> views/controller/fun1.html
>
>
> {{extend layout.html}}
>
> {{=content}}
>
>
> views/controller/fun2.html
>
>
> {{extend layout.html}}
>
> {{=content}}
>
>
> The alternative would be:
>
>
> # controller.py
>
>
> def fun1():
>
> return { }
>
>
> def fun2():
>
> return { }
>
>
> and views:
>
>
> views/controller/fun1.html
>
>
> {{extend layout.html}}
>
> 'Hello'
>
> 'this is my first app World'
>
>
> views/controller/fun2.html
>
>
> {{extend layout.html}}
>
> 'Hello Again'
>
> 'this is the second page'
>
>
> What is the difference, which is better practice? In this simple case 
> which pattern is it advisable I follow?
>
>
> Thank you
>

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


[web2py] Re: how to disable the form.

2015-06-21 Thread Anthony
You might consider doing this in the controller:

if datetime.timedelta(days=2) > (t-question.created_on):
[el.update(_disabled=True) for el in form.elements('input')]

You could also handle it in Javascript.

Anthony

On Sunday, June 21, 2015 at 12:13:03 PM UTC-4, Chaitu P wrote:
>
> Is there any way that I can disable complete form instead of each 
> element.Because I want to have the same format in both the cases.
> Here is my code of view...
>
> {{=question.body}}
> 
> {{if datetime.timedelta(days=2)>(t-question.created_on):}}
> {{=form}}
> {{else:}}
> 
> Name  
> Email 
> 
> 
> {{pass}}
>
>

-- 
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: background image

2015-06-21 Thread Ron Chatterjee
Responding to this old thread. When I do the ...in the background 
image, the entire image is filled up in the page. How do I specify pixel 
(how much width and height)?

I tried ; width:10px; height:10px. But it still filles the entire screen 
with the image. 



On Wednesday, September 18, 2013 at 7:03:40 PM UTC-4, Alex Glaros wrote:
>
> thanks Massimo,
>
> I think you're right to be concerned that this is the wrong approach 
>
> I wanted to add a small image, logo, just below the navbar.  I was 
> concerned that the image might shift over on top of text on devices that I 
> haven't tested yet, so I thought that as background image, text that 
> unexpectedly shifted over it could safely be readable.
>
> I'll study how other people handle this and try later.  This is a temp fix 
> below but pages actually look cleaner without the image anyway.
>