[web2py] -K startup

2017-05-25 Thread Dave S
I've finally put my fingers on certbot, and have my 443 responding (now I'm 
a good boy).  This server hosts 2 applications, each of which runs a 
scheduler.  For various reasons, I do my -K's separate from the main 
listening process. It occurred to me to wonder, as I did the start/restart 
commands, to wonder if these -K commands need the -i, -p, -c, and/or -k 
that the main worker needs.


(Yeah, I'm still using Rocket, but volume is still low, so I can postpone 
learning nginx until my tutor is available.)

/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: Field('upload') : problem with file name

2017-05-25 Thread Dave S


On Wednesday, May 24, 2017 at 9:37:17 PM UTC-7, Wabbajack wrote:
>
> Hi Massimo,
>
> Still has this issue... :(
>
> I am using 2.14.6 web2py running in windows7 with pydal 17.03 and python 
> 2.7
>
>
> I have this filename 54 characters (including '.pdf ')
>
>
>
>
> This is the field on my db.py
>
>
> After i add a record including an upload file  this is the Error
>
> Adding record including upload file
>
>
>
>
> Need help on resolving this issue since i cannot control the filename 
> length of the user will upload
> Also i check the length newfilename length and including its path hope it 
> helps
>
>
>
>
> The error is directing to this file
>
>
>
> I also tried changing my field with length value but still error upon 
> adding files with upload
>
>
> Thank you in advance,
> Jak
>
>  
If you're opening a file on the server, then the length of the absolute 
path may matter.  If your application folder is deeply nested, than that 
could be a problem.  On Windows, your choices

   - move your web2py (and application) folder nearer the root of the 
   filesystem
   - assign a drive letter to the path (shortening the total path) ... this 
   may be the old alias command, but it's been a while since I did this
   - use Window's version of links to provide a shorter path (I think this 
   became "real" in XP, but again I haven't done this in a while).

Note that you do have some control over the length of the filename:

   - you can reject names that are too long, usually done in the form
   - you can rename the file to a shorter name, and separately track the 
   original name

Note that my experience includes having the web2py folder in a path like 

c:/users/mememe/web2py_win/web2py-2.14.6/web2py

That's a fair-sized headstart on total pathlength,

but so far I haven't had any users (any of me) produce a filename that 
caused a problem.


On a linux system where actual users upload files, the longest name (as 
stored) is 235 characters, and the path is 57 characters.  The filename is 
actually generated by a non-web program that we control, and sent via 
libcurl.  The name encodes some information relevant to the client.


/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: Problems with file uploading using FORM

2017-05-25 Thread Dave S


On Thursday, May 25, 2017 at 8:34:44 AM UTC-7, Maurice Ling wrote:
>
> Hi everyone,
>
> I am stuck with an issue - please refer to the code below.
>
> [...]
>
5. I will the want to copy the file into application//upload 
> folder using shutils (lines 17-25) but the file name will be changed to 
> entry.file..
> 6. However, this does not work as I get the error that the file is not 
> found. 
> 7. For debugging, I print the source file name (line 21) and it only gave 
> me the file name when I will need the entire file path for shutil.copy2() 
> at line 25 to work.
> *[...]* 
>
   sourcefile = form.vars.uploadfile.filename
>

>1. print sourcefile
>2. newfile = upload_dir + os.sep + 'entry.file.' + \
>3. str(int(random.random()*10)) + \
>4. os.path.splitext(sourcefile)[-1]
>5. shutil.copy2(sourcefile, newfile)
>6. 
>
> [...]
>
 
A browser won't tell you the path to the file, just the filename.  It's a 
security measure.  The shutil.copy2() call can only handle files local to 
the server.  If you're using this page locally on the server, then you can 
provide the path information through other channels.

I do something like this on my home machine, because I'm using my app to 
tag my photos.   Currently, I provide a text field on the form to enter 
path (separate from filename), but I check that path against a list I keep 
in the code.  That limits the amount filesystem exploration someone could 
do if they somehow got access to my app.
(BTW, drag-and-drop works for getting the filename into its field).

/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: Codec MS-SQL, unicode Latin1 UTF8

2017-05-25 Thread tim . nyborg
I use this same stack, and ran into encoding issues when updating the 
database, because of FreeTDS v.91.

But upgrading to FreeTDS v1.00.40 fixed all unicode issues:
https://github.com/mkleehammer/pyodbc/issues/244

Connect with mssql4n, TDS_Version 7.1+, no need to set db_codec

On Friday, 19 May 2017 02:07:27 UTC+1, Jose wrote:
>
> Hi J-Michel Angers
>
> Given:
> pydal <-> pyodbc  <-> UnixODBC  <-> FreeTDS  <-> MSSQL
>
> In freetds.conf I have:
>
> client charset = UTF-8
>
> and in pydal I use mssql2 adapter, db_codec is not necessary
>
> Jose
>

-- 
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] Problems with file uploading using FORM

2017-05-25 Thread Maurice Ling
Hi everyone,

I am stuck with an issue - please refer to the code below.

1. I have a form (new_entry function)  that I will like to use to be able 
to upload a file among other fields.
2. I am using FORM instead of SQLFORM because one of the dropdown fields 
(line 11) in the form is generated at run time.
3. The way that I did was to use input file type (line 9) to open a file 
selection browser / window to select the file - this works OK.
4. If form.vars.uploadfile is not empty, it means that a file had been 
selected for uploading.
5. I will the want to copy the file into application//upload 
folder using shutils (lines 17-25) but the file name will be changed to 
entry.file..
6. However, this does not work as I get the error that the file is not 
found. 
7. For debugging, I print the source file name (line 21) and it only gave 
me the file name when I will need the entire file path for shutil.copy2() 
at line 25 to work.

*Can someone assist?*

Any help will be greatly appreciated.

Thank in advance and warm regards

Maurice Ling


   1. def new_entry():
   2. if session.username == None: redirect(request.env.http_referer + 
   "account/log_in")
   3. # get unarchived notebooks
   4. else:
   5. notebook = [notebook['name'] for notebook in 
   cydb(cydb.notebook.archived == False).select(cydb.notebook.name)]
   6. notebook.sort()
   7. form = FORM(TABLE(
   8. TR('Title: ', INPUT(_type='text', _name='title', 
   _size=80)),
   9. TR('File: ', INPUT(_type='file', _name='uploadfile')),
   10. TR('tags: ', INPUT(_type='text', _name='tags', 
   _size=80)),
   11. TR('Notebook: ', SELECT(notebook, _name='notebook')),
   12. TR('Description: ', TEXTAREA(_type='text', 
   _name='description'),
   13. TR('',INPUT(_type='submit', _name='SUBMIT')
   14. if form.accepts(request.vars, session):
   15. notebook = cydb(cydb.notebook.name == 
   form.vars.notebook).select(cydb.notebook.id).as_list()[0]['id']
   16. if form.vars.uploadfile != '':
   17. # upload file into applications//upload 
   folder
   18. import os, random, shutil
   19. upload_dir = os.sep.join([os.getcwd(), 
   'applications', request.application, 'uploads'])
   20. sourcefile = form.vars.uploadfile.filename
   21. print sourcefile
   22. newfile = upload_dir + os.sep + 'entry.file.' + \
   23. str(int(random.random()*10)) + \
   24. os.path.splitext(sourcefile)[-1]
   25. shutil.copy2(sourcefile, newfile)
   26. cydb.ent.insert(title=form.vars.title,
   27.  author=session.username,
   28.  notebook=notebook_id,
   29.  tags=form.vars.tags,
   30.  file=newfile.split(os.sep)[-1],
   31.  filename=newfile.split(os.sep)[-1],
   32.  description=form.vars.description)
   33. else:
   34. # no file to upload
   35. cydb.ent.insert(title=form.vars.title,
   36.  author=session.username,
   37.  notebook=id,
   38.  tags=form.vars.tags,
   39.  file='',
   40.  filename='',
   41.  description=form.vars.description)
   42. bb.tape.insert(event='New entry created. %s. Title = 
   %s'% \
   43. 
   (cydb(cydb.notebook.id==notebook_id).select(cydb.notebook.name),
   44. form.vars.title),
   45. user=session.username)
   46. response.flash='your entry has been successfully added'
   47. return dict(form=form)


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


[web2py] Re: styling smartgrid New/Edit/View forms

2017-05-25 Thread Anthony
You could create a custom formstyle function and then pass it to the grid 
via the "formargs" argument or set response.formstyle.

Anthony

On Thursday, May 25, 2017 at 4:50:58 AM UTC-4, icodk wrote:
>
> Background
> My model has a table with many fields (62). When using smartgrid to edit 
> or add a record, all fields are shown in a long vertical list in the same 
> order as defined in the model. So log so good.
> This can be overwhelming to user that might need to see some of the fields 
> very often and some others less frequently.
> One way to solve this could be to show the fields in separate tabs that 
> groups the fields according to some designation. Here is an example
> Model:
>
> db.define_table('person',
> Field('first_name',tab='General', label=T('First name'), 
> default='',length=50),
>
> Field('last_name',tab='General', label=T('Last name'), 
> default='',length=50),
>
>Field('phone',tab='Advance',label=T('phone'), default=''),
>
> Field('visits',tab='Statistics','integer' label=T('Visits'), 
> default=0))
>
>
> In the above model I added an imaginary tab property (which will cause en 
> error in real application)  to group  fields with the same tab property 
> under the same tab in a detail smartgrid form.
> To solve the order of the tabs, the call to the smartgrid will include a 
> 'tab' property which will be a list with tabs.
>
> Another more flexible solution  could be to add a 'tab ' property to 
>  smartgrid which will be a dictionary with tab names as keys and a lists of 
>  field names as values. This will allow also to order the fields on each 
> tab and will not require any change to the existing define_table structure.
>
> Example:
> tabs={'General':['first_name','last_name'],'Advance':['phone'],
> 'Statistics':['visits']}
>
> I have this strange filling that this is already possible, may be 
> something to do with formstyle.
> Any help will be appreciated
>

-- 
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: Azure deployment recommendations?

2017-05-25 Thread Brian M
Yes, if necessary I could run a Linux VM in Azure but since everything else 
is Windows based just sticking with that would be easiest. We could go for 
a full Windows VM in Azure too but I was hoping to be able to give it a go 
with the Web App Service and not have to worry about maintaining the OS. 
Perhaps the scheduler can be run as a WebJob, looks like you can run 
command line stuff with that so maybe just the usual scheduler commandline 
invocation without the need for nssm?

Brian

On Thursday, May 25, 2017 at 12:03:35 AM UTC-5, Dave S wrote:
>
>
>
> On Wednesday, May 24, 2017 at 7:10:48 PM UTC-7, Brian M wrote:
>>
>> I'm looking to try deploying a web2py app on Azure. Is the route 
>> mentioned here 
>>  still the 
>> best approach? Since running scheduled tasks will be a significant part of 
>> the app, has anybody tried using the web2py scheduler (as a Windows service 
>> via NSSM) on Azure? Any tips or recommendations would be appreciated.
>>
>> Thanks, Brian M
>>
>
> I understand that Azure allows Linux guests, so you may not be stuck with 
> NSSM.
>
> /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] styling smartgrid New/Edit/View forms

2017-05-25 Thread icodk
Background
My model has a table with many fields (62). When using smartgrid to edit or 
add a record, all fields are shown in a long vertical list in the same 
order as defined in the model. So log so good.
This can be overwhelming to user that might need to see some of the fields 
very often and some others less frequently.
One way to solve this could be to show the fields in separate tabs that 
groups the fields according to some designation. Here is an example
Model:

db.define_table('person',
Field('first_name',tab='General', label=T('First name'), 
default='',length=50),

Field('last_name',tab='General', label=T('Last name'), 
default='',length=50),

   Field('phone',tab='Advance',label=T('phone'), default=''),

Field('visits',tab='Statistics','integer' label=T('Visits'), 
default=0))


In the above model I added an imaginary tab property (which will cause en 
error in real application)  to group  fields with the same tab property 
under the same tab in a detail smartgrid form.
To solve the order of the tabs, the call to the smartgrid will include a 
'tab' property which will be a list with tabs.

Another more flexible solution  could be to add a 'tab ' property to 
 smartgrid which will be a dictionary with tab names as keys and a lists of 
 field names as values. This will allow also to order the fields on each 
tab and will not require any change to the existing define_table structure.

Example:
tabs={'General':['first_name','last_name'],'Advance':['phone'],'Statistics'
:['visits']}

I have this strange filling that this is already possible, may be something 
to do with formstyle.
Any help will be appreciated

-- 
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: grid edit

2017-05-25 Thread T.R.Rajkumar
I googled and saw this https://www.drupal.org/node/2342699 where it is 
stated that SqlContentEntityStorage::mapToStorageRecord sends update 
statements that includes IDENTITY fields that need to be updated, such as: 
UPDATE xxx SET nid = 1, property0 = :value0 WHERE nid = 1;. This is not 
supported in SQL Server because although there is no actual update 
happening it is explicitly telling the database engine that you wish to 
perform an update.

and here https://www.drupal.org/node/2090251  it is said The underlying 
problem is that MySQL accepts identity updates (when there are no changes) 
but Sql Server being properly designed complains with this bad practice.

Is this the issue in web2py also.
 

-- 
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: Is web2py incompatible with 2nd generation Google Cloud SQL ?

2017-05-25 Thread Karoly Kantor
I have temporarily solved this problem, as described here:

https://groups.google.com/forum/?fromgroups=#!topic/web2py/vs39zZpaH7g

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