[web2py] Re: Auto-completion and the ajax function bug web2py manual (p. 472 )

2012-10-22 Thread martzi
Possible solution: use  vars=dict(id=*row.id*) instead of args=*row.id* in 
this case the Url will be something like this
 
http://127.0.0.1:8000/AjaxApp/default/month_input?id=1
05 this will enable the auto-completion to work across any page where it's 
used with parameterized url.*
*
On Monday, October 22, 2012 4:51:47 PM UTC+2, martzi wrote:
>
> Hi all,
> following the example on auto-completion in web2py manual, there seems to 
> be a "bug" using the ajax function with parameterized url.
> accessing the page normally in my case with  (
> http://127.0.0.1:8000/AjaxApp/default/month_input) then try typing any 
> month of the year - works fine.
> but  accessing the page with args say 1,  like so =>( 
> http://127.0.0.1:8000/AjaxApp/default/month_input/1 ) then try typing any 
> month of the year and something weird happens.
>
> Please has anyone experienced across the same problem ?
>

-- 





Re: [web2py] Re: ProgrammingError: Cannot operate on a closed database

2012-10-22 Thread hasan alnator
Dear Martin,

i am using web2py 1.9.9  on a windows server , everything is fine but i
keep getting this error everything i update web2py to the new one , i hope
you can help me to solve this problem ..

Regards,

On Mon, Oct 22, 2012 at 11:31 PM, Martin Weissenboeck wrote:

> I have tried several things, but I am not sure what solved the problem:
>
>- DAL with pool_size=10
>- All Linux-files got the same rights (755)
>
> Sorry, I think this is not much help.
>
>
> 2012/10/22 hasan alnator 
>
>> Dear Cliff,
>>
>> Can you give me more guides on how to apply this ?
>>
>> Best Regards,
>>
>>
>>
>> On Mon, Oct 22, 2012 at 10:30 PM, Cliff Kachinske wrote:
>>
>>> You can install Linux alongside Windows using the dual boot option.
>>>  That way you won't have to manually ensure file perms are correct.
>>>
>>> I ran this way for a time, but then I dropped Windows completely.
>>>
>>>
>>> On Wednesday, September 19, 2012 1:51:23 PM UTC-4, mweissen wrote:

 Solved.
 The permission of a lot files have been wrong:
 I develop an application on a windows system and the target system is a
 linux machine. Some permissions got wrong values after copying the
 application files.


 2012/9/17 Massimo Di Pierro 

> You error seems to indicate there is a lock object in session. Can you
> try check by printing the session.keys() before saving the session?
>
>
> On Monday, 17 September 2012 12:54:54 UTC-5, mweissen wrote:
>
>> Yes, I have stored a lot of information in session, but only strings
>> and dicts. The application works fine on my development pc (a windows 7
>> pc). The problem arises after I have put the application on the target
>> machine (ubuntu with apache2).
>>
>> 2012/9/17 Massimo Di Pierro 
>>
>> Looks like the problem is that you try pus something in session that
>>> is not pickleable.
>>>
>>>
>>> On Monday, 17 September 2012 02:59:54 UTC-5, mweissen wrote:
>>>
 From the /var/log/apache2/error.log:

 [Mon Sep 17 09:39:09 2012] [error] ERROR:web2py:Traceback (most
 recent call last):
 [Mon Sep 17 09:39:09 2012] [error]   File
 "/users/www-data/web2py/gluon/**main.py", line 547, in wsgibase
 [Mon Sep 17 09:39:09 2012] [error] session._try_store_on_disk(*
 *request, response)
 [Mon Sep 17 09:39:09 2012] [error]   File
 "/users/www-data/web2py/gluon/**globals.py", line 686, in
 _try_store_on_disk
 [Mon Sep 17 09:39:09 2012] [error] cPickle.dump(dict(self),
 response.session_file)
 [Mon Sep 17 09:39:09 2012] [error]   File
 "/usr/lib/python2.7/copy_reg.**py", line 70, in _reduce_ex
 [Mon Sep 17 09:39:09 2012] [error] raise TypeError, "can't
 pickle %s objects" % base.__name__
 [Mon Sep 17 09:39:09 2012] [error] TypeError: can't pickle lock
 objects
 [Mon Sep 17 09:39:09 2012] [error]


 2012/9/17 Paolo 

 Dear all,
> occasionally, I am getting this error too (with and without
> lazy_table)
> Which OS are you using ?
> Could you post your db model?
>
> Paolo
>
>
> On Monday, September 17, 2012 7:21:42 AM UTC+2, mweissen wrote:
>>
>> I have read some threads about this error message -  I got it too:
>>
>> Version  web2py™ (2, 0, 9, datetime.datetime(2012, 9, 13, 23,
>> 51, 30), 'stable')  Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>> 21.
>> 22.
>> 23.
>> 24.
>> 25.
>> 26.
>> 27.
>>
>> Traceback (most recent call last):
>>   File "/users/www-data/web2py/gluon/main.py", line 547, in 
>> wsgibase
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> session._try_store_on_disk(request, response)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>   File "/users/www-data/web2py/gluon/globals.py", line 686, 
>> in _try_store_on_disk
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> cPickle.dump(dict(self), response.session_file)
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>   File "/usr/lib/python2.7/copy_reg.**p**y", line 74, in 
>> _reduce_ex
>

Re: [web2py] Re: Dropbox Error : to many values to unpack

2012-10-22 Thread hasan alnator
Dear Massimo ,

i changed it , but now i got this :

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/dropbox/controllers/default.py"
,
line 82, in 
  File "C:\web2py\gluon\globals.py", line 187, in 
self._caller = lambda f: f()
  File "C:/web2py/applications/dropbox/controllers/default.py"
,
line 44, in user
return dict(form=auth())
  File "C:\web2py\gluon\tools.py", line 1205, in __call__
return getattr(self,args[0])()
  File "C:\web2py\gluon\tools.py", line 2016, in login
cas_user = cas.get_user()
  File "C:\web2py\gluon\contrib\login_methods\dropbox_account.py",
line 62, in get_user
access_token = self.sess.obtain_access_token(self.sess.token)
  File "applications\dropbox\modules\dropbox\session.py", line 205, in
obtain_access_token
response = self.rest_client.POST(url, headers=headers,
params=params, raw_response=True)
  File "applications\dropbox\modules\dropbox\rest.py", line 260, in POST
return cls.IMPL.POST(*n, **kw)
  File "applications\dropbox\modules\dropbox\rest.py", line 207, in POST
post_params=params, headers=headers, raw_response=raw_response)
  File "applications\dropbox\modules\dropbox\rest.py", line 183, in request
raise ErrorResponse(r)
ErrorResponse: [401] u'Token is disabled or invalid'


Regards,


On Tue, Oct 23, 2012 at 12:23 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Typo in the book:
>
> from gluon.contrib.login_methods.dr**opbox_account import use_dropbox
> use_dropbox(auth,filename='**private/dropbox.key')
> mydropbox = auth.settings.login_form
>
>
> On Monday, 22 October 2012 11:39:26 UTC-5, Hassan Alnatour wrote:
>
>> Dear Massimo ,
>>
>> i got this from the book :
>>
>> from gluon.contrib.login_methods.dr**opbox_account import use_dropbox
>> use_janrain(auth,filename='**private/dropbox.key')
>> mydropbox = auth.settings.login_form
>>
>>
>> http://web2py.com/books/**default/chapter/29/14?search=**
>> dropbox#Dropbox-API
>>
>> Best Regards,
>>
>>
>> On Mon, Oct 22, 2012 at 7:14 PM, Massimo Di Pierro > > wrote:
>>
>>> You cannot use janrain with dropbox. They are different APIs and use
>>> different keys. Look into
>>>
>>> gluon/contrib/login_methods/**dropbox_account.py
>>>
>>> for examples
>>>
>>>
>>> On Monday, 22 October 2012 08:11:13 UTC-5, Hassan Alnatour wrote:

 Dear ALL ,

 i am trying to work with dropbox API i addedthe file dropbox.key in 
 app/private and added the keys in it , i added the dropbox module and i am 
 getting this error , any help ?


 regards,


 Traceback (most recent call last):

   File "C:\web2py\gluon\restricted.**py**", line 209, in restricted

 exec ccode in environment
   File "C:/web2py/applications/**dropbo**x/models/db.py" 
 , line 67, 
 in 

 use_janrain(auth,filename='**pri**vate/dropbox.key')

   File "C:\web2py\gluon\contrib\**login**_methods\rpx_account.py", line 
 121, in use_janrain

 domain,key = open(path,'r').read().strip().split(':')
 ValueError: too many values to unpack

  --
>>>
>>>
>>>
>>>
>>
>>  --
>
>
>
>

-- 





[web2py] Re: IS_NOT_IN_DB() and update SQLFORM.factory

2012-10-22 Thread Annet
Hi Villas,

Thanks for your reply. I tried:

is_not_in_db=IS_NOT_IN_DB(db,'hub.name',error_message='name already in 
database')

db.define_table('hub',
Field(...),

Field('name',default='',requires=[IS_NOT_EMPTY(),is_not_in_db],notnull=True,unique=True),
Field(...),
migrate=False)

But I still cannot update hub. I put the validators inside the field 
definition because I want to make use of lazy_tables=True


Kind regards,

Annet

-- 





Re: [web2py] buttons=['submit','reset','cancel'] and INPUT helpers

2012-10-22 Thread Annet
Hi Richard,

Thanks for your reply and providing me with the link. This does exactly 
what I want:

form.element('input[type=submit]',replace=lambda button: CAT(button, 
INPUT(_class="btn",_type="reset",_value="Reset"), 
INPUT(_class="btn",_type="button",_value="Cancel",_onclick="javascript:history.go(-1);")))


Kind regards,

Annet

-- 





[web2py] Re: DB filled with data, now what? How to operate with view?

2012-10-22 Thread howesc
yes, i would do the query in the controller, and output my custom HTML in 
the view that uses CSS to indent the  or whichever HTML element that 
you use to get your layout.

cfh

On Monday, October 22, 2012 1:30:04 PM UTC-7, MJo wrote:
>
> I've got scheduler working and DB is getting data. Now the funny part 
> starts for newbie like me (scheduler were somewhat easy stuff but basics 
> like html&css not and add there also this framework to that soup).. How to 
> show that data?
>
> Am I supposed to utilize controllers/default.py:
> def index():
> to return some dictionary?
>
> DB is something like:
>
>forename  surname  parent-id
> 1. John Smith
> 2. Lisa  Jefferson
> 3. RickySmith  1
>
> So John has boy Ricky.
>
> I would like to layout web-page as:
>
> John Smith
> Ricky Smith
> Lisa Jefferson
>
> So shall I do DB call on controller to return everything using dictionary 
> and do parsing (put Ricky as indented/under related to John) on view? Or 
> should I somehow forget controller and just do everything on view? What is 
> the "right way"?
>
> I guess I have to use  and/or  like spell among css3 to 
> format it using good practices and current de facto standards.
>

-- 





[web2py] Re: routes_onerror

2012-10-22 Thread lyn2py
I confirm that this issue still exists in
Version 2.2.1 (2012-10-22 18:50:13) stable



On Wednesday, September 26, 2012 5:16:47 PM UTC+8, lyn2py wrote:
>
> Opened an issue here: 
> Issue 1034 
>
> On Wednesday, September 26, 2012 11:16:16 AM UTC+8, Massimo Di Pierro 
> wrote:
>>
>> Please open a ticket about this. 
>>
>> On Tuesday, 25 September 2012 21:36:57 UTC-5, lyn2py wrote:
>>>
>>> Can't use it in an app-specicfic routes. It works once I moved it to the 
>>> main routes.py
>>>
>>>
>>> On Sunday, September 23, 2012 9:35:11 AM UTC+8, lyn2py wrote:

 I have this code in the *app-specific* routes.py

 routes_onerror = [
   ('*/*', '/myapp/static/error.html')
 ]

 I reload routes, but it still prints 
 invalid function (nothing/here)

 I am using:
 Version 2.0.9 (2012-09-17 21:37:10) stable

 May I know what I am doing wrong?

 Thank you.

>>>

-- 





[web2py] Re: APP-specific routers

2012-10-22 Thread lyn2py
I have just tested this on the latest
Version 2.2.1 (2012-10-22 18:50:13) stable

But it is still not working.


On Wednesday, October 3, 2012 12:24:08 PM UTC+8, lyn2py wrote:
>
> The new (or maybe not so new, by now) app-specific routers is an excellent 
> idea. I love it. 
>
> Can I get some help regarding the use of it?
>
> The following code is in my routes.py file, but it doesn't seem to work:
> routers = {
> app: dict(
> default_language = possible_languages['default'][0],
> languages = [lang for lang in possible_languages
>if lang != 'default'],
> default_controller = 'default', #I added this
> default_function = 'index', #and this
> )
> }
> I added the two lines but it isn't working. (per the comments)
> I have tried both reloading routes and restarting the server.
> Is the syntax incorrect? Thanks!
>
>

-- 





[web2py] response.toolbar, missing db stats?

2012-10-22 Thread lyn2py
db stats used to produce the SQL code and the db access timings whenever 
the controller has code that accesses the db.

But I found that db stats is missing this info in
Version 2.1.1 (2012-10-19 14:59:27) dev
And the latest git clone
Version 2.2.1 (2012-10-22 18:50:13) stable


-- 





[web2py] Re: auth.requires_membership changed between 1.99.2 and 2.1.1 ?

2012-10-22 Thread Cliff Kachinske
Thanks.

Actually I already have a fix in place, though I like yours better because 
it's more compact.  I was just wondering if the Web2py behavior had changed.

On Monday, October 22, 2012 4:53:07 PM UTC-4, Niphlod wrote:
>
> Don't take this as a sure thing, but a big improvement was made on 
> 1.99.4/1.99.7 to avoid the behaviour that all decorators (as @auth.requires 
> is) were executed no matter what function you were requesting for that 
> controller. Don't know if that fix brought to your situation.
> I think your situation can be easily fixed though: before you had a 
> default=None for that field, so just set a variable before the table 
> definition as
>
> tenant_field = session.auth.user.request_tenant if session.auth.user or 
> None
>
> and use tenant_field instead of session.auth.user.request_tenant for the 
> default value of the field.
>
> On Monday, October 22, 2012 10:10:16 PM UTC+2, Cliff Kachinske wrote:
>>
>> My models reference session.auth.user as follows:
>>
>> Field('request_tenant', default=session.auth.user.request_tenant)
>>
>> Obviously this will fail if the user is not logged in because 
>> session.auth.user is None.
>>
>> In 1.99.2, using any of the @auth decorators forces a login before the 
>> model files run, so there is no problem.
>>
>> In 2.1.1, errors occur.  It seems like the models are being run before 
>> the decorators have been evaluated, whereas in 1.99.2 the decorators were 
>> evaluated first.
>>
>> Has something changed in Web2py?
>>
>> The applicable model files are identical, according to diff. The 
>> controllers are not, but I made no changes to the index functions and I get 
>> the error when running index.
>>
>> Any idea what's going on?
>>
>

-- 





[web2py] Access a pandas pickled file

2012-10-22 Thread curiouslearn
Hello,

I have a pandas data frame saved using 

pandas.save('simdata_1_1.pickle')


I can load it easily in my regular ipython console (not the web2py ipython 
console) using 

pandas.load('simdata_1_1.pickle')

I was wondering if I can use this file in a web2py application, such as 
extract data from it and then plot it using a javascript library such as 
d3.js. 
To try this I copied the file in the static folder of my application and 
then added the following controller function in my application:

def readData():
df = pandas.load('../static/simdata_1_1.pickle')
return dict()

If I visit the 
page http://127.0.0.1:8000/priceDecisions/default/readData.html I get the 
following error. What am I doing wrong? Would appreciate some help.
TICKET ID

127.0.0.1.2012-10-22.22-21-10.f129b298-a65e-4d29-8965-b483a444a2bd
 [Errno 2] No such file or directory: 
'../static/simdata_1_1.pickle'VERSIONweb2py™(2, 0, 9, 
datetime.datetime(2012, 9, 13, 23, 51, 30), 'stable')PythonPython 2.7.2: 
/Library/Frameworks/Python.framework/Versions/7.2/Resources/Python.app/Contents/MacOS/Python

-- 





[web2py] Re: update_or_insert doesn't always return the corresponding row id

2012-10-22 Thread Adi
Stumbled upon the same thing.

Understood that possibly results could  have more ids when key is different 
from primary key, e.g (name=='john'), but would it be possible to return an 
additional parameter with update id(s), if they are known? 

return newid, updateids


On Friday, December 30, 2011 12:31:37 PM UTC-5, olivier wrote:
>
> The "insert" method returns the id of the inserted row. 
> The "update_or_insert" method returns the id of the inserted row, but 
> returns None in case of an update... 
>
> Why is it so? 
>
> I have a case in which I want to update_or_insert and then further 
> update the corresponding row (to track the status of a long running 
> process). 
> I would rather have the method to always output the id of the updated/ 
> inserted row... 
> Or is there any use-case you would like to discriminate between the 
> fact you inserted or update a row? 
>
> What do you think? 
>
>   -Olivier 
>
>
> From dal.py (I added the proposed modification) 
> === 
>
> def update_or_insert(self, key=DEFAULT, **values): 
>   if key==DEFAULT: 
> record = self(**values) 
>   else: 
> record = self(key) 
>if record: 
> record.update_record(**values) 
> newid = None  #--> why not record['id']  
>else: 
>  newid = self.insert(**values) 
>return newid

-- 





[web2py] Re: Erase/re-populate elements from a , depending on another ?

2012-10-22 Thread villas
You need to search for jquery cascading select.  I think there is something 
on web2pyslices too.  I went to check the latter but the internet/website 
was so slow I gave up.   Probably just a temporary slow-down.  D

On Monday, October 22, 2012 8:47:55 PM UTC+1, apinho wrote:
>
> Hello,
>
> Having :
>
> 
> Countries :
> 
> Portugal
> Spain
> 
> Cities
> 
>  Lisbon
>  Barcelona
>  Madrid
>  Porto
> 
>  
>
>
> How can I get a form that dynamically limits 'cities' options, according 
> to the chosen country ?
>  
> I mean : If user chooses Spain, he should only have Barcelona/Madrid 
> available.
>
> I guess it envolves 'onchange' html attribute, and some jquery, but I 
> google up and got no straight answers.
>
> Thank you
>
>
>

-- 





Re: [web2py] Web2py 2.1.1 csv import bug or ?

2012-10-22 Thread Massimo Di Pierro
Fixed in 2.2.1

On Monday, 22 October 2012 18:02:29 UTC-5, Tito Garrido wrote:
>
> I have the same problem... is it a bug?
>
> On Wed, Oct 17, 2012 at 5:51 AM, martzi  >wrote:
>
>> Hello all,
>>
>> I have being trying to import a csv data to a DAL database and this is 
>> what i get:
>> 
>> Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>>
>> Traceback (most recent call last):
>>   File "/home/xxx/Documents/web2py211/gluon/restricted.py", line 209, in 
>> restricted
>>
>>
>> exec ccode in environment
>>   File 
>> "/home/xxxDocuments/web2py211/applications/appx/controllers/appadmin.py" 
>> ,
>>  line 447, in 
>>
>>
>>   File "/home/xxx/Documents/web2py211/gluon/globals.py", line 187, in 
>> 
>>
>>
>> self._caller = lambda f: f()
>>
>>
>>   File 
>> "/home/xxx/Documents/web2py211/applications/appx/controllers/appadmin.py" 
>> ,
>>  line 255, in select
>>
>>
>> tb = tb,
>> UnboundLocalError: local variable 'tb' referenced before assignment
>>
>> ...
>>  Has anyone come across similar problem ?
>>
>> -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 





Re: [web2py] web2py.css and bootstrap

2012-10-22 Thread Paolo Caruccio
The margin is required when the html code is generated by web2py in one 
string without line breaks and the elements are "inline elements" (as the 
"input" element is).

Please in a view put following code

case #1
{{=DIV(INPUT(_type='text',_value='first 
element'),'\n',INPUT(_type='text',_value='second 
element'),INPUT(_type='text',_value='third element'))}}

case #2
{{=DIV(INPUT(_type='text',_value='first 
element',_style='margin-right:4px;'),INPUT(_type='text',_value='second 
element'),INPUT(_type='text',_value='third element'))}}

case #3

 
 
 


case #4


In cases #1 and #2 we have a space between first and second element, but not 
between 
the second and third elements.
Case #3 shows the correct rendering (the code is in a block)
Case #4 shows the wrong rendering (the code is in a line)

To solve the issue you should override the css rule in web2py.css:

.input-append>input
{
margin-right:0;
}




Il giorno lunedì 22 ottobre 2012 22:40:53 UTC+2, Richard ha scritto:
>
> Hello,
>
> This line in web2py.css prevent the use of "Prepended and appended inputs" 
> of the bootstrap :
>
> Line 33 of web2py.css (web2py 2.1.1)
> input[type=text],input[type=password],select{width:300px; margin-right:5px}
>
> The problem come from the "margin-right:5px"
>
> There should be not margin-right in order to allow the .add-on button to 
> be paste just below the input field...
>
> In order to test it someone could just use Chrome and inspect a input 
> field append "input-append" to the field div class (formstyle=divs) :
> Ex.: class="w2p_fw input-append" 
> Append a span like this one to the field div :
> .00
> And set a id to the input :
> id="appendedInput"
> But this not seems to be required even if it explained like this on 
> bootstrap site.
>
>
> Why do we use the margin-right for? Could it be removed or replaced by a 
> container and magin-left ?
>
> Richard
>  
>

-- 



<>

Re: [web2py] Web2py 2.1.1 csv import bug or ?

2012-10-22 Thread Tito Garrido
I have the same problem... is it a bug?

On Wed, Oct 17, 2012 at 5:51 AM, martzi  wrote:

> Hello all,
>
> I have being trying to import a csv data to a DAL database and this is
> what i get:
> 
> Traceback
>
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
>
>
> Traceback (most recent call last):
>   File "/home/xxx/Documents/web2py211/gluon/restricted.py", line 209, in 
> restricted
>
> exec ccode in environment
>   File 
> "/home/xxxDocuments/web2py211/applications/appx/controllers/appadmin.py" 
> ,
>  line 447, in 
>
>   File "/home/xxx/Documents/web2py211/gluon/globals.py", line 187, in 
>
> self._caller = lambda f: f()
>
>   File 
> "/home/xxx/Documents/web2py211/applications/appx/controllers/appadmin.py" 
> ,
>  line 255, in select
>
> tb = tb,
> UnboundLocalError: local variable 'tb' referenced before assignment
>
> ...
>  Has anyone come across similar problem ?
>
> --
>
>
>
>



-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





[web2py] Re: grid export button

2012-10-22 Thread Paolo Caruccio
My fault. I extrapoled the code from more complex one.

Try this:

{{extend 'layout.html'}}
{{
w2p_grid_tbl = grid.element('table')
if w2p_grid_tbl:
 original_export_menu = grid.element('div.w2p_export_menu')
 export_menu_links = original_export_menu.elements('a')
 export_menu_items = []
 for link in export_menu_links:
 item = LI(link)
 export_menu_items.append(item)
 pass
 new_export_menu = DIV(
  A( T('Exports'),
 SPAN(_class='caret'),
 _href='#',
 _class='btn dropdown-toggle',
 **{'_data-toggle':"dropdown"}
),
  UL(*export_menu_items,
 _class='dropdown-menu'
),
_class='w2p_export_menu btn-group'
)
 export_menu = grid.element('div.w2p_export_menu',replace=new_export_menu)
pass
}}

{{=grid}}

Of course you could modify the DOM directly in the controller.



Il giorno lunedì 22 ottobre 2012 22:56:48 UTC+2, Omi Chiba ha scritto:
>
> Wow! This is exactly what I wanted. I hope this will be the default layout 
> for grid.
>
> I copy and pasted your code between {{extend 'layout.html'}} and 
> {{=gird}}, then export labels are now disappeard...
> Maybe you should check your code with the latest (2.1.1). 
>
> {{left_sidebar_enabled,right_sidebar_enabled=False,('message' in 
> globals())}}
> {{extend 'layout.html'}}
> {{
> w2p_grid_tbl = grid.element('table')
> if w2p_grid_tbl:
>  export_menu = grid.element('div.w2p_export_menu')
>  export_menu_links = export_menu.elements('a')
>  export_menu_items = []
>  for link in export_menu_links:
>  item = LI(link)
>  export_menu_items.append(item)
>  pass
>  export_menu = grid.element('div.w2p_export_menu',replace=None)
>  new_export_menu = DIV(
>   A( T('Exports'),
>  SPAN(_class='caret'),
>  _href='#',
>  _class='btn dropdown-toggle',
>  **{'_data-toggle':"dropdown"}
> ),
>   UL(*export_menu_items,
>  _class='dropdown-menu'
> ),
> _class='w2p_export_menu btn-group'
> )
> pass
> }}
>
> {{=grid}}
>
>
>
>
> On Monday, October 22, 2012 2:10:53 PM UTC-5, Paolo Caruccio wrote:
>>
>> For grid export menu I'm happy with below method
>>
>> In the views/*.html file where is your grid put on top (just below extend 
>> layout command)  the following code:
>>
>> {{
>> w2p_grid_tbl = grid.element('table')
>> if w2p_grid_tbl:
>>  export_menu = grid.element('div.w2p_export_menu')
>>  export_menu_links = export_menu.elements('a')
>>  export_menu_items = []
>>  for link in export_menu_links:
>>  item = LI(link)
>>  export_menu_items.append(item)
>>  pass
>>  export_menu = grid.element('div.w2p_export_menu',replace=None)
>>  new_export_menu = DIV(
>>   A( T('Exports'),
>>  SPAN(_class='caret'),
>>  _href='#',
>>  _class='btn dropdown-toggle',
>>  **{'_data-toggle':"dropdown"}
>> ),
>>   UL(*export_menu_items,
>>  _class='dropdown-menu'
>> ),
>> _class='w2p_export_menu btn-group'
>> )
>> pass
>> }}
>>
>> In the attached picture you can see how the exports menu is rendered 
>> using css bootstrap framework.
>>
>> The method is based on Server-side DOM and parsing (
>> http://web2py.com/books/default/chapter/29/05#Server-side-DOM-and-parsing) 
>> and it uses the elements argument "replace" (new beatiful and powerful - in 
>> my opinion - feature). For reference you could read 
>> https://groups.google.com/forum/?fromgroups=#!topic/web2py/fbYZXoIOkCY
>>
>> I hope this will help you.
>>
>>  
>>
>> Il giorno lunedì 22 ottobre 2012 17:15:37 UTC+2, Omi Chiba ha scritto:
>>>
>>> New export function on grid has many choices but I need to keep the old 
>>> format. (Export button for csv) because...
>>>
>>> - I'm using the gird for users (Maybe this format is good for us but not 
>>> users.)
>>> - Current export options layout is not pretty (I prefer button with 
>>> dropdown list)
>>> - I don't want users to see hidden columns
>>>
>>> Is there any option available for me?
>>>
>>>

-- 





Re: [web2py] Re: scheduler and update

2012-10-22 Thread Martin Weissenboeck
Thank you very much - db.commit() is the solution!

2012/10/22 Niphlod 

> all code in the scheduler runs as you were running the function in the
> shell (as web2py.py -M -S yourapp)
>
> There's no "automatic" support for committing changes when the task is
> completed like there is the one when the request completes on web2py.
>
> You should call db.commit() in your functions wherever you need to save
> data to the db (or just call it at the end of the function)
>
>
>
> On Monday, October 22, 2012 10:12:05 PM UTC+2, mweissen wrote:
>>
>> Let's say I have a table
>>
>> db.define_table('sendprot',
>>   Field('myfield','integer', default=0))
>>
>> and a function like
>>
>> def testupdate():
>> db.sendprot[1]=dict(myfield=2)
>>
>> Now I make this function a scheduler function and I set the
>> scheduler_task.status to QUEUED
>> The status becomes COMPLETED. Looks fine, but myfield did not change.
>>
>> A scheduler function can read a database table, but does it an insert or
>> an update?
>>
>> web2py last version, runs on a Linux computer.
>>
>> Regards, Martin
>>
>>
>>

-- 





[web2py] Re: How to check if a given user in logged in an external private python script?

2012-10-22 Thread Niphlod
the only thing you know about a user "logged in" is that his session has a 
session.auth key with data filled in. You can't know without further 
modification to web2py's code if a user is logged in in any other way.
So, you need to read the session files (all of them).
Session files are usually stored into 
yourapplication/sessions/remoteip.uuid files.
This files are in "pickle" format, so you must unpickle them and read as 
they were a dictionary.

import cPickle
with open(session_file, 'rb') as session:
 data = cPickle.loads(session.read())
 print data

"data" contains the session data. Elaborate further your processing logic 
as you wish



On Monday, October 22, 2012 11:28:18 PM UTC+2, Saurabh Kumar wrote:
>
> Hi, can you elaborate a bit more on as to how to do this in code? I am 
> somewhat confused.
>
> On Monday, October 22, 2012 8:34:21 AM UTC-4, Niphlod wrote:
>>
>> you must load all the session files, unpickle them and see if there is an 
>> auth.user key in it.
>>
>> On Monday, October 22, 2012 12:55:12 PM UTC+2, Saurabh Kumar wrote:
>>>
>>> By external python script, I mean a python script run using following 
>>> command:
>>>
>>> python web2py.py -S app_name -M -R 
>>> applications/app_name/private/script.py
>>>
>>> I have to check if the user with a given user_id is 'logged in' inside 
>>> this script.
>>>
>>

-- 





[web2py] Re: Custom import creates module name conflicts (2.1.1)

2012-10-22 Thread Jim Karsten
Thanks, Massimo.

I upgraded to web2py v2.2.1 and that patch addresses the 'ImportError: 
cannot import name web2py_uuid' error.

I still have name clashes with my constants.py module and MySQLdb. For now 
I am going to rename my module. I have some reservations about the new 
custom_importer as it can produce these clash problems and there is little 
I can do to prepare for them or protect my code from them.

On Friday, October 19, 2012 7:37:44 PM UTC-4, Massimo Di Pierro wrote:
>
> Good catch. Fixed in trunk
>
> On Friday, 19 October 2012 16:54:54 UTC-5, Jim Karsten wrote:
>>
>> I upgraded to v 2.1.1 and now see problems with module name conflicts due 
>> to the custom importer. Previously I used v2.0.9 without problems.
>>
>> I have a custom application module named utils.py. This appears to 
>> conflict with the gluon.utils module. I was able to simulate using the 
>> basic web2py zip file and then creating a simple module 
>> applications/welcome/modules/utils.py. When I access the welcome default 
>> page, I get this error: 
>>
>> Traceback (most recent call last): 
>> File "/root/tmp/web2py/web2py/gluon/restricted.py", line 209, 
>> in restricted exec ccode in environment 
>> File "/root/tmp/web2py/web2py/applications/welcome/models/db.py", line 
>> 42, 
>> in from gluon.tools import Auth, Crud, Service, PluginManager, prettydate 
>> File "/root/tmp/web2py/web2py/gluon/custom_import.py", line 89, 
>> in custom_importer return 
>> NATIVE_IMPORTER(name,globals,locals,fromlist,level)
>> File "/root/tmp/web2py/web2py/gluon/tools.py", line 30, in from utils 
>> import web2py_uuid 
>> ImportError: cannot import name web2py_uuid 
>>
>> I disabled the custom importer by issuing a return immediately in 
>> gluon/custom_import.py def custom_import_install() and the problem goes 
>> away. 
>>
>> I can also correct this specific issue if I change this line in 
>> gluon/tools.py 
>>
>> -from utils import web2py_uuid 
>> +from gluon.utils import web2py_uuid 
>>
>> This last change works, but it isn't a complete solution. For example, in 
>> another application I have a constants.py module. It is conflicting with a 
>> constants module MySQLdb makes use of. Deep in the code of MySQLdb there is 
>> a line:
>>
>> from constants import CLIENT, FIELD_TYPE 
>>
>> That import fails as it tries to find those classes in my custom module. 
>> I can always rename my custom module, but this becomes a cat and mouse 
>> game. I can't know every module name already in use. 
>>
>> Any suggestions for this? It's a bit of a show stopper for me. Perhaps an 
>> option should be available to disable the custom importer. 
>
>

-- 





[web2py] Re: How to check if a given user in logged in an external private python script?

2012-10-22 Thread Saurabh Kumar
Hi, can you elaborate a bit more on as to how to do this in code? I am 
somewhat confused.

On Monday, October 22, 2012 8:34:21 AM UTC-4, Niphlod wrote:
>
> you must load all the session files, unpickle them and see if there is an 
> auth.user key in it.
>
> On Monday, October 22, 2012 12:55:12 PM UTC+2, Saurabh Kumar wrote:
>>
>> By external python script, I mean a python script run using following 
>> command:
>>
>> python web2py.py -S app_name -M -R applications/app_name/private/script.py
>>
>> I have to check if the user with a given user_id is 'logged in' inside 
>> this script.
>>
>

-- 





Re: [web2py] Re: Dropbox Error : to many values to unpack

2012-10-22 Thread Massimo Di Pierro
Typo in the book:

from gluon.contrib.login_methods.dropbox_account import use_dropbox
use_dropbox(auth,filename='private/dropbox.key')
mydropbox = auth.settings.login_form


On Monday, 22 October 2012 11:39:26 UTC-5, Hassan Alnatour wrote:
>
> Dear Massimo , 
>
> i got this from the book :
>
> from gluon.contrib.login_methods.dropbox_account import use_dropbox
> use_janrain(auth,filename='private/dropbox.key')
> mydropbox = auth.settings.login_form
>
>
> http://web2py.com/books/default/chapter/29/14?search=dropbox#Dropbox-API
>
> Best Regards,
>
>
> On Mon, Oct 22, 2012 at 7:14 PM, Massimo Di Pierro 
> 
> > wrote:
>
>> You cannot use janrain with dropbox. They are different APIs and use 
>> different keys. Look into 
>>
>> gluon/contrib/login_methods/dropbox_account.py
>>
>> for examples
>>
>>
>> On Monday, 22 October 2012 08:11:13 UTC-5, Hassan Alnatour wrote:
>>>
>>> Dear ALL , 
>>>
>>> i am trying to work with dropbox API i addedthe file dropbox.key in 
>>> app/private and added the keys in it , i added the dropbox module and i am 
>>> getting this error , any help ?
>>>
>>>
>>> regards,
>>>
>>>
>>> Traceback (most recent call last):
>>>
>>>   File "C:\web2py\gluon\restricted.**py", line 209, in restricted
>>>
>>> exec ccode in environment
>>>   File "C:/web2py/applications/**dropbox/models/db.py" 
>>> , line 67, 
>>> in 
>>>
>>> use_janrain(auth,filename='**private/dropbox.key')
>>>
>>>   File "C:\web2py\gluon\contrib\**login_methods\rpx_account.py", line 121, 
>>> in use_janrain
>>>
>>> domain,key = open(path,'r').read().strip().**split(':')
>>> ValueError: too many values to unpack
>>>
>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: grid export button

2012-10-22 Thread Omi Chiba
Wow! This is exactly what I wanted. I hope this will be the default layout 
for grid.

I copy and pasted your code between {{extend 'layout.html'}} and {{=gird}}, 
then export labels are now disappeard...
Maybe you should check your code with the latest (2.1.1). 

{{left_sidebar_enabled,right_sidebar_enabled=False,('message' in 
globals())}}
{{extend 'layout.html'}}
{{
w2p_grid_tbl = grid.element('table')
if w2p_grid_tbl:
 export_menu = grid.element('div.w2p_export_menu')
 export_menu_links = export_menu.elements('a')
 export_menu_items = []
 for link in export_menu_links:
 item = LI(link)
 export_menu_items.append(item)
 pass
 export_menu = grid.element('div.w2p_export_menu',replace=None)
 new_export_menu = DIV(
  A( T('Exports'),
 SPAN(_class='caret'),
 _href='#',
 _class='btn dropdown-toggle',
 **{'_data-toggle':"dropdown"}
),
  UL(*export_menu_items,
 _class='dropdown-menu'
),
_class='w2p_export_menu btn-group'
)
pass
}}

{{=grid}}




On Monday, October 22, 2012 2:10:53 PM UTC-5, Paolo Caruccio wrote:
>
> For grid export menu I'm happy with below method
>
> In the views/*.html file where is your grid put on top (just below extend 
> layout command)  the following code:
>
> {{
> w2p_grid_tbl = grid.element('table')
> if w2p_grid_tbl:
>  export_menu = grid.element('div.w2p_export_menu')
>  export_menu_links = export_menu.elements('a')
>  export_menu_items = []
>  for link in export_menu_links:
>  item = LI(link)
>  export_menu_items.append(item)
>  pass
>  export_menu = grid.element('div.w2p_export_menu',replace=None)
>  new_export_menu = DIV(
>   A( T('Exports'),
>  SPAN(_class='caret'),
>  _href='#',
>  _class='btn dropdown-toggle',
>  **{'_data-toggle':"dropdown"}
> ),
>   UL(*export_menu_items,
>  _class='dropdown-menu'
> ),
> _class='w2p_export_menu btn-group'
> )
> pass
> }}
>
> In the attached picture you can see how the exports menu is rendered using 
> css bootstrap framework.
>
> The method is based on Server-side DOM and parsing (
> http://web2py.com/books/default/chapter/29/05#Server-side-DOM-and-parsing) 
> and it uses the elements argument "replace" (new beatiful and powerful - in 
> my opinion - feature). For reference you could read 
> https://groups.google.com/forum/?fromgroups=#!topic/web2py/fbYZXoIOkCY
>
> I hope this will help you.
>
>  
>
> Il giorno lunedì 22 ottobre 2012 17:15:37 UTC+2, Omi Chiba ha scritto:
>>
>> New export function on grid has many choices but I need to keep the old 
>> format. (Export button for csv) because...
>>
>> - I'm using the gird for users (Maybe this format is good for us but not 
>> users.)
>> - Current export options layout is not pretty (I prefer button with 
>> dropdown list)
>> - I don't want users to see hidden columns
>>
>> Is there any option available for me?
>>
>>

-- 





[web2py] Re: auth.requires_membership changed between 1.99.2 and 2.1.1 ?

2012-10-22 Thread Niphlod
Don't take this as a sure thing, but a big improvement was made on 
1.99.4/1.99.7 to avoid the behaviour that all decorators (as @auth.requires 
is) were executed no matter what function you were requesting for that 
controller. Don't know if that fix brought to your situation.
I think your situation can be easily fixed though: before you had a 
default=None for that field, so just set a variable before the table 
definition as

tenant_field = session.auth.user.request_tenant if session.auth.user or None

and use tenant_field instead of session.auth.user.request_tenant for the 
default value of the field.

On Monday, October 22, 2012 10:10:16 PM UTC+2, Cliff Kachinske wrote:
>
> My models reference session.auth.user as follows:
>
> Field('request_tenant', default=session.auth.user.request_tenant)
>
> Obviously this will fail if the user is not logged in because 
> session.auth.user is None.
>
> In 1.99.2, using any of the @auth decorators forces a login before the 
> model files run, so there is no problem.
>
> In 2.1.1, errors occur.  It seems like the models are being run before the 
> decorators have been evaluated, whereas in 1.99.2 the decorators were 
> evaluated first.
>
> Has something changed in Web2py?
>
> The applicable model files are identical, according to diff. The 
> controllers are not, but I made no changes to the index functions and I get 
> the error when running index.
>
> Any idea what's going on?
>

-- 





[web2py] web2py.css and bootstrap

2012-10-22 Thread Richard
Hello,

This line in web2py.css prevent the use of "Prepended and appended inputs" 
of the bootstrap :

Line 33 of web2py.css (web2py 2.1.1)
input[type=text],input[type=password],select{width:300px; margin-right:5px}

The problem come from the "margin-right:5px"

There should be not margin-right in order to allow the .add-on button to be 
paste just below the input field...

In order to test it someone could just use Chrome and inspect a input field 
append "input-append" to the field div class (formstyle=divs) :
Ex.: class="w2p_fw input-append" 
Append a span like this one to the field div :
.00
And set a id to the input :
id="appendedInput"
But this not seems to be required even if it explained like this on 
bootstrap site.


Why do we use the margin-right for? Could it be removed or replaced by a 
container and magin-left ?

Richard
 

-- 





[web2py] Re: scheduler and update

2012-10-22 Thread Niphlod
all code in the scheduler runs as you were running the function in the 
shell (as web2py.py -M -S yourapp)

There's no "automatic" support for committing changes when the task is 
completed like there is the one when the request completes on web2py.

You should call db.commit() in your functions wherever you need to save 
data to the db (or just call it at the end of the function)


On Monday, October 22, 2012 10:12:05 PM UTC+2, mweissen wrote:
>
> Let's say I have a table
>
> db.define_table('sendprot',
>   Field('myfield','integer', default=0))
>
> and a function like
>
> def testupdate():
> db.sendprot[1]=dict(myfield=2)
>
> Now I make this function a scheduler function and I set the 
> scheduler_task.status to QUEUED
> The status becomes COMPLETED. Looks fine, but myfield did not change.
>
> A scheduler function can read a database table, but does it an insert or 
> an update?
>
> web2py last version, runs on a Linux computer.
>
> Regards, Martin
>
>
>
>

-- 





Re: [web2py] Re: ProgrammingError: Cannot operate on a closed database

2012-10-22 Thread Martin Weissenboeck
I have tried several things, but I am not sure what solved the problem:

   - DAL with pool_size=10
   - All Linux-files got the same rights (755)

Sorry, I think this is not much help.

2012/10/22 hasan alnator 

> Dear Cliff,
>
> Can you give me more guides on how to apply this ?
>
> Best Regards,
>
>
>
> On Mon, Oct 22, 2012 at 10:30 PM, Cliff Kachinske wrote:
>
>> You can install Linux alongside Windows using the dual boot option.  That
>> way you won't have to manually ensure file perms are correct.
>>
>> I ran this way for a time, but then I dropped Windows completely.
>>
>>
>> On Wednesday, September 19, 2012 1:51:23 PM UTC-4, mweissen wrote:
>>>
>>> Solved.
>>> The permission of a lot files have been wrong:
>>> I develop an application on a windows system and the target system is a
>>> linux machine. Some permissions got wrong values after copying the
>>> application files.
>>>
>>>
>>> 2012/9/17 Massimo Di Pierro 
>>>
 You error seems to indicate there is a lock object in session. Can you
 try check by printing the session.keys() before saving the session?


 On Monday, 17 September 2012 12:54:54 UTC-5, mweissen wrote:

> Yes, I have stored a lot of information in session, but only strings
> and dicts. The application works fine on my development pc (a windows 7
> pc). The problem arises after I have put the application on the target
> machine (ubuntu with apache2).
>
> 2012/9/17 Massimo Di Pierro 
>
> Looks like the problem is that you try pus something in session that
>> is not pickleable.
>>
>>
>> On Monday, 17 September 2012 02:59:54 UTC-5, mweissen wrote:
>>
>>> From the /var/log/apache2/error.log:
>>>
>>> [Mon Sep 17 09:39:09 2012] [error] ERROR:web2py:Traceback (most
>>> recent call last):
>>> [Mon Sep 17 09:39:09 2012] [error]   File
>>> "/users/www-data/web2py/gluon/**main.py", line 547, in wsgibase
>>> [Mon Sep 17 09:39:09 2012] [error] session._try_store_on_disk(**
>>> request, response)
>>> [Mon Sep 17 09:39:09 2012] [error]   File
>>> "/users/www-data/web2py/gluon/**globals.py", line 686, in
>>> _try_store_on_disk
>>> [Mon Sep 17 09:39:09 2012] [error] cPickle.dump(dict(self),
>>> response.session_file)
>>> [Mon Sep 17 09:39:09 2012] [error]   File
>>> "/usr/lib/python2.7/copy_reg.**py", line 70, in _reduce_ex
>>> [Mon Sep 17 09:39:09 2012] [error] raise TypeError, "can't
>>> pickle %s objects" % base.__name__
>>> [Mon Sep 17 09:39:09 2012] [error] TypeError: can't pickle lock
>>> objects
>>> [Mon Sep 17 09:39:09 2012] [error]
>>>
>>>
>>> 2012/9/17 Paolo 
>>>
>>> Dear all,
 occasionally, I am getting this error too (with and without
 lazy_table)
 Which OS are you using ?
 Could you post your db model?

 Paolo


 On Monday, September 17, 2012 7:21:42 AM UTC+2, mweissen wrote:
>
> I have read some threads about this error message -  I got it too:
>
> Version  web2py™ (2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51,
> 30), 'stable')  Traceback
>
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
> 21.
> 22.
> 23.
> 24.
> 25.
> 26.
> 27.
>
>
> Traceback (most recent call last):
>   File "/users/www-data/web2py/gluon/main.py", line 547, in 
> wsgibase
>
>
>
>
>
>
>
>
>
>
> session._try_store_on_disk(request, response)
>
>
>
>
>
>
>
>
>
>
>   File "/users/www-data/web2py/gluon/globals.py", line 686, 
> in _try_store_on_disk
>
>
>
>
>
>
>
>
>
>
> cPickle.dump(dict(self), response.session_file)
>
>
>
>
>
>
>
>
>
>
>   File "/usr/lib/python2.7/copy_reg.**p**y", line 74, in 
> _reduce_ex
>
>
>
>
>
>
>
>
>
>
> getstate = self.__getstate__
>   File "/users/www-data/web2py/gluon/dal.py", line 7344, in 
> __getattr__
>
>
>
>
>
>
>
>
>
>
> self.__allocate()
>   File "/users/www-data/web2py/gluon/dal.py", line 7337, in 
> __allocate
>>>

[web2py] DB filled with data, now what? How to operate with view?

2012-10-22 Thread MJo
I've got scheduler working and DB is getting data. Now the funny part 
starts for newbie like me (scheduler were somewhat easy stuff but basics 
like html&css not and add there also this framework to that soup).. How to 
show that data?

Am I supposed to utilize controllers/default.py:
def index():
to return some dictionary?

DB is something like:

   forename  surname  parent-id
1. John Smith
2. Lisa  Jefferson
3. RickySmith  1

So John has boy Ricky.

I would like to layout web-page as:

John Smith
Ricky Smith
Lisa Jefferson

So shall I do DB call on controller to return everything using dictionary 
and do parsing (put Ricky as indented/under related to John) on view? Or 
should I somehow forget controller and just do everything on view? What is 
the "right way"?

I guess I have to use  and/or  like spell among css3 to 
format it using good practices and current de facto standards.

-- 





Re: [web2py] Re: scheduler and datetime

2012-10-22 Thread Martin Weissenboeck
I have written it now  :-)

2012/10/22 Niphlod 

> I can't see the other email but glad the problem is solved on the
> scheduler side.
>
>
> On Monday, October 22, 2012 10:00:40 PM UTC+2, mweissen wrote:
>
>> Sorry, yesterday it has been very late. Of course some code is necessary
>> for analyzing. I thought it could be helpful it there is a simple problem.
>>
>> Yes, a function calls the the scheduler. Now I have changed the code and
>> did not get the message again. But now there is another problem - see other
>> mail.
>>
>> Regards, Martin
>>
>> 2012/10/21 Niphlod 
>>
>> Without code to reproduce it's hard to give you any clue on how to fix
>>> thisWhat is the web2py version? Can we see the function ? Seems that
>>> the result of the function is calling scheduler code againcan you tell
>>> us more about what are you trying to do ?
>>>
>>> are you doing in some places in your models
>>>
>>> from datetime import datetime ?
>>>
>>>
>>> On Sunday, October 21, 2012 11:36:23 PM UTC+2, mweissen wrote:

 I get this error message:

 Traceback (most recent call last):
   File "/users/www-data/web2py/gluon/scheduler.py", line 232, in
 executor
 result = dumps(_function(*args, **vars))
   File "applications/secure/models/**sc**hedule.py", line 742, in
 redirect_email
 message=str(rueckmeldung)+'\n'+str(T('Ihre E-Mail mit dem
 folgenden Text kann nicht weiter geleitet werden:'))+'\n\n'+empfangene_
 **e**mail['body'],
   File "applications/secure/models/**sc**hedule.py", line 174, in
 queue_email
 timeout=120,
   File "/users/www-data/web2py/gluon/dal.py", line 7806, in insert
 ret =  self._db._adapter.insert(self,self._listify(fields))
   File "/users/www-data/web2py/gluon/dal.py", line 1155, in insert
 query = self._insert(table,fields)
   File "/users/www-data/web2py/gluon/dal.py", line 1151, in _insert
 values = ','.join(self.expand(v,f.type) for f,v in fields)
   File "/users/www-data/web2py/gluon/dal.py", line 1151, in
 
 values = ','.join(self.expand(v,f.type) for f,v in fields)
   File "/users/www-data/web2py/gluon/dal.py", line 1306, in expand
 return str(self.represent(expression,field_type))
   File "/users/www-data/web2py/gluon/dal.py", line 1699, in
 represent
 obj = obj()
   File "/users/www-data/web2py/gluon/scheduler.py", line 455, in
 now
 return self.utc_time and datetime.datetime.utcnow() or
 datetime.datetime.now()
 AttributeError: type object 'datetime.datetime' has no attribute
 'datetime'


  --
>>>
>>  --
>
>

-- 





Re: [web2py] Re: scheduler and datetime

2012-10-22 Thread Niphlod
I can't see the other email but glad the problem is solved on the scheduler 
side.

On Monday, October 22, 2012 10:00:40 PM UTC+2, mweissen wrote:
>
> Sorry, yesterday it has been very late. Of course some code is necessary 
> for analyzing. I thought it could be helpful it there is a simple problem.
>
> Yes, a function calls the the scheduler. Now I have changed the code and 
> did not get the message again. But now there is another problem - see other 
> mail.
>
> Regards, Martin
>
> 2012/10/21 Niphlod >
>
>> Without code to reproduce it's hard to give you any clue on how to fix 
>> thisWhat is the web2py version? Can we see the function ? Seems that 
>> the result of the function is calling scheduler code againcan you tell 
>> us more about what are you trying to do ?
>>
>> are you doing in some places in your models 
>>
>> from datetime import datetime ?
>>
>>
>> On Sunday, October 21, 2012 11:36:23 PM UTC+2, mweissen wrote:
>>>
>>> I get this error message:
>>>
>>> Traceback (most recent call last):
>>>   File "/users/www-data/web2py/gluon/**scheduler.py", line 232, in 
>>> executor
>>> result = dumps(_function(*args, **vars))
>>>   File "applications/secure/models/**schedule.py", line 742, in 
>>> redirect_email
>>> message=str(rueckmeldung)+'\n'**+str(T('Ihre E-Mail mit dem 
>>> folgenden Text kann nicht weiter geleitet werden:'))+'\n\n'+empfangene_*
>>> *email['body'],
>>>   File "applications/secure/models/**schedule.py", line 174, in 
>>> queue_email
>>> timeout=120,
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7806, in insert
>>> ret =  self._db._adapter.insert(self,**self._listify(fields))
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 1155, in insert
>>> query = self._insert(table,fields)
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 1151, in _insert
>>> values = ','.join(self.expand(v,f.type) for f,v in fields)
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 1151, in 
>>> values = ','.join(self.expand(v,f.type) for f,v in fields)
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 1306, in expand
>>> return str(self.represent(expression,**field_type))
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 1699, in represent
>>> obj = obj()
>>>   File "/users/www-data/web2py/gluon/**scheduler.py", line 455, in now
>>> return self.utc_time and datetime.datetime.utcnow() or 
>>> datetime.datetime.now()
>>> AttributeError: type object 'datetime.datetime' has no attribute 
>>> 'datetime'
>>>
>>>
>>>  -- 
>>
>

-- 





[web2py] Re: I have a generated pdf file I want to return to the view...

2012-10-22 Thread Niphlod
if you have generated a physical file

response.stream(path_to_pshysical_file, attachment=True, 
filename=whatever.pdf)
if you have a "virtual file" (e.g., StringIO)
response.stream(virtual_file, attachment=True, filename=whatever.pdf)

On Monday, October 22, 2012 9:33:21 PM UTC+2, encompass wrote:
>
> How do I return a file to the view? 
> Is there a way to give it a file name as it comes out? 
> It's a PDF file I generated in the controller.  I think I can get it as 
> a file like object too. 
> As a bonus, how do I delete it after it has been downloaded. (Thought I 
> could easily do that in a cron job.) 
> BR, 
> Jason Brower 
>

-- 





[web2py] scheduler and update

2012-10-22 Thread Martin Weissenboeck
Let's say I have a table

db.define_table('sendprot',
  Field('myfield','integer', default=0))

and a function like

def testupdate():
db.sendprot[1]=dict(myfield=2)

Now I make this function a scheduler function and I set the
scheduler_task.status to QUEUED
The status becomes COMPLETED. Looks fine, but myfield did not change.

A scheduler function can read a database table, but does it an insert or an
update?

web2py last version, runs on a Linux computer.

Regards, Martin

-- 





[web2py] auth.requires_membership changed between 1.99.2 and 2.1.1 ?

2012-10-22 Thread Cliff Kachinske
My models reference session.auth.user as follows:

Field('request_tenant', default=session.auth.user.request_tenant)

Obviously this will fail if the user is not logged in because 
session.auth.user is None.

In 1.99.2, using any of the @auth decorators forces a login before the 
model files run, so there is no problem.

In 2.1.1, errors occur.  It seems like the models are being run before the 
decorators have been evaluated, whereas in 1.99.2 the decorators were 
evaluated first.

Has something changed in Web2py?

The applicable model files are identical, according to diff. The 
controllers are not, but I made no changes to the index functions and I get 
the error when running index.

Any idea what's going on?

-- 





Re: [web2py] Re: ProgrammingError: Cannot operate on a closed database

2012-10-22 Thread hasan alnator
Dear Cliff,

Can you give me more guides on how to apply this ?

Best Regards,



On Mon, Oct 22, 2012 at 10:30 PM, Cliff Kachinske  wrote:

> You can install Linux alongside Windows using the dual boot option.  That
> way you won't have to manually ensure file perms are correct.
>
> I ran this way for a time, but then I dropped Windows completely.
>
>
> On Wednesday, September 19, 2012 1:51:23 PM UTC-4, mweissen wrote:
>>
>> Solved.
>> The permission of a lot files have been wrong:
>> I develop an application on a windows system and the target system is a
>> linux machine. Some permissions got wrong values after copying the
>> application files.
>>
>>
>> 2012/9/17 Massimo Di Pierro 
>>
>>> You error seems to indicate there is a lock object in session. Can you
>>> try check by printing the session.keys() before saving the session?
>>>
>>>
>>> On Monday, 17 September 2012 12:54:54 UTC-5, mweissen wrote:
>>>
 Yes, I have stored a lot of information in session, but only strings
 and dicts. The application works fine on my development pc (a windows 7
 pc). The problem arises after I have put the application on the target
 machine (ubuntu with apache2).

 2012/9/17 Massimo Di Pierro 

 Looks like the problem is that you try pus something in session that is
> not pickleable.
>
>
> On Monday, 17 September 2012 02:59:54 UTC-5, mweissen wrote:
>
>> From the /var/log/apache2/error.log:
>>
>> [Mon Sep 17 09:39:09 2012] [error] ERROR:web2py:Traceback (most
>> recent call last):
>> [Mon Sep 17 09:39:09 2012] [error]   File
>> "/users/www-data/web2py/gluon/**main.py", line 547, in wsgibase
>> [Mon Sep 17 09:39:09 2012] [error] session._try_store_on_disk(**
>> request, response)
>> [Mon Sep 17 09:39:09 2012] [error]   File
>> "/users/www-data/web2py/gluon/**globals.py", line 686, in
>> _try_store_on_disk
>> [Mon Sep 17 09:39:09 2012] [error] cPickle.dump(dict(self),
>> response.session_file)
>> [Mon Sep 17 09:39:09 2012] [error]   File
>> "/usr/lib/python2.7/copy_reg.**py", line 70, in _reduce_ex
>> [Mon Sep 17 09:39:09 2012] [error] raise TypeError, "can't pickle
>> %s objects" % base.__name__
>> [Mon Sep 17 09:39:09 2012] [error] TypeError: can't pickle lock
>> objects
>> [Mon Sep 17 09:39:09 2012] [error]
>>
>>
>> 2012/9/17 Paolo 
>>
>> Dear all,
>>> occasionally, I am getting this error too (with and without
>>> lazy_table)
>>> Which OS are you using ?
>>> Could you post your db model?
>>>
>>> Paolo
>>>
>>>
>>> On Monday, September 17, 2012 7:21:42 AM UTC+2, mweissen wrote:

 I have read some threads about this error message -  I got it too:

 Version  web2py™ (2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51,
 30), 'stable')  Traceback

 1.
 2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.
 17.
 18.
 19.
 20.
 21.
 22.
 23.
 24.
 25.
 26.
 27.

 Traceback (most recent call last):
   File "/users/www-data/web2py/gluon/main.py", line 547, in 
 wsgibase








 session._try_store_on_disk(request, response)








   File "/users/www-data/web2py/gluon/globals.py", line 686, in 
 _try_store_on_disk








 cPickle.dump(dict(self), response.session_file)








   File "/usr/lib/python2.7/copy_reg.**p**y", line 74, in _reduce_ex








 getstate = self.__getstate__
   File "/users/www-data/web2py/gluon/dal.py", line 7344, in 
 __getattr__








 self.__allocate()
   File "/users/www-data/web2py/gluon/dal.py", line 7337, in 
 __allocate








 self._record = self._table[int(self)]








   File "/users/www-data/web2py/gluon/dal.py", line 7624, in 
 __getitem__








 return self._db(self._id == 
 key).select(limitby=(0,1)).first()








   File "/u

Re: [web2py] Re: scheduler and datetime

2012-10-22 Thread Martin Weissenboeck
Sorry, yesterday it has been very late. Of course some code is necessary
for analyzing. I thought it could be helpful it there is a simple problem.

Yes, a function calls the the scheduler. Now I have changed the code and
did not get the message again. But now there is another problem - see other
mail.

Regards, Martin

2012/10/21 Niphlod 

> Without code to reproduce it's hard to give you any clue on how to fix
> thisWhat is the web2py version? Can we see the function ? Seems that
> the result of the function is calling scheduler code againcan you tell
> us more about what are you trying to do ?
>
> are you doing in some places in your models
>
> from datetime import datetime ?
>
>
> On Sunday, October 21, 2012 11:36:23 PM UTC+2, mweissen wrote:
>>
>> I get this error message:
>>
>> Traceback (most recent call last):
>>   File "/users/www-data/web2py/gluon/**scheduler.py", line 232, in
>> executor
>> result = dumps(_function(*args, **vars))
>>   File "applications/secure/models/**schedule.py", line 742, in
>> redirect_email
>> message=str(rueckmeldung)+'\n'**+str(T('Ihre E-Mail mit dem
>> folgenden Text kann nicht weiter geleitet werden:'))+'\n\n'+empfangene_**
>> email['body'],
>>   File "applications/secure/models/**schedule.py", line 174, in
>> queue_email
>> timeout=120,
>>   File "/users/www-data/web2py/gluon/**dal.py", line 7806, in insert
>> ret =  self._db._adapter.insert(self,**self._listify(fields))
>>   File "/users/www-data/web2py/gluon/**dal.py", line 1155, in insert
>> query = self._insert(table,fields)
>>   File "/users/www-data/web2py/gluon/**dal.py", line 1151, in _insert
>> values = ','.join(self.expand(v,f.type) for f,v in fields)
>>   File "/users/www-data/web2py/gluon/**dal.py", line 1151, in 
>> values = ','.join(self.expand(v,f.type) for f,v in fields)
>>   File "/users/www-data/web2py/gluon/**dal.py", line 1306, in expand
>> return str(self.represent(expression,**field_type))
>>   File "/users/www-data/web2py/gluon/**dal.py", line 1699, in represent
>> obj = obj()
>>   File "/users/www-data/web2py/gluon/**scheduler.py", line 455, in now
>> return self.utc_time and datetime.datetime.utcnow() or
>> datetime.datetime.now()
>> AttributeError: type object 'datetime.datetime' has no attribute
>> 'datetime'
>>
>>
>>  --
>

-- 





[web2py] Erase/re-populate elements from a , depending on another ?

2012-10-22 Thread apinho
Hello,

Having :


Countries :

Portugal
Spain

Cities

 Lisbon
 Barcelona
 Madrid
 Porto

 


How can I get a form that dynamically limits 'cities' options, according to 
the chosen country ?
 
I mean : If user chooses Spain, he should only have Barcelona/Madrid 
available.

I guess it envolves 'onchange' html attribute, and some jquery, but I 
google up and got no straight answers.

Thank you


-- 





[web2py] I have a generated pdf file I want to return to the view...

2012-10-22 Thread Jason Brower

How do I return a file to the view?
Is there a way to give it a file name as it comes out?
It's a PDF file I generated in the controller.  I think I can get it as 
a file like object too.
As a bonus, how do I delete it after it has been downloaded. (Thought I 
could easily do that in a cron job.)

BR,
Jason Brower

--





Re: [web2py] Re: ProgrammingError: Cannot operate on a closed database

2012-10-22 Thread Cliff Kachinske
You can install Linux alongside Windows using the dual boot option.  That 
way you won't have to manually ensure file perms are correct.

I ran this way for a time, but then I dropped Windows completely.

On Wednesday, September 19, 2012 1:51:23 PM UTC-4, mweissen wrote:
>
> Solved.
> The permission of a lot files have been wrong: 
> I develop an application on a windows system and the target system is a 
> linux machine. Some permissions got wrong values after copying the 
> application files.
>
>
> 2012/9/17 Massimo Di Pierro >
>
>> You error seems to indicate there is a lock object in session. Can you 
>> try check by printing the session.keys() before saving the session?
>>
>>
>> On Monday, 17 September 2012 12:54:54 UTC-5, mweissen wrote:
>>
>>> Yes, I have stored a lot of information in session, but only strings and 
>>> dicts. The application works fine on my development pc (a windows 7 pc). 
>>> The problem arises after I have put the application on the target machine 
>>> (ubuntu with apache2).
>>>
>>> 2012/9/17 Massimo Di Pierro 
>>>
>>> Looks like the problem is that you try pus something in session that is 
 not pickleable.


 On Monday, 17 September 2012 02:59:54 UTC-5, mweissen wrote:

> From the /var/log/apache2/error.log:
>
> [Mon Sep 17 09:39:09 2012] [error] ERROR:web2py:Traceback (most recent 
> call last):
> [Mon Sep 17 09:39:09 2012] [error]   File 
> "/users/www-data/web2py/gluon/main.py", line 547, in wsgibase
> [Mon Sep 17 09:39:09 2012] [error] session._try_store_on_disk(**
> req**uest, response)
> [Mon Sep 17 09:39:09 2012] [error]   File 
> "/users/www-data/web2py/gluon/globals.py", line 686, in 
> _try_store_on_disk
> [Mon Sep 17 09:39:09 2012] [error] cPickle.dump(dict(self), 
> response.session_file)
> [Mon Sep 17 09:39:09 2012] [error]   File "/usr/lib/python2.7/copy_reg.
> **p**y", line 70, in _reduce_ex
> [Mon Sep 17 09:39:09 2012] [error] raise TypeError, "can't pickle 
> %s objects" % base.__name__
> [Mon Sep 17 09:39:09 2012] [error] TypeError: can't pickle lock objects
> [Mon Sep 17 09:39:09 2012] [error]
>
>
> 2012/9/17 Paolo 
>
> Dear all,
>> occasionally, I am getting this error too (with and without 
>> lazy_table)
>> Which OS are you using ?
>> Could you post your db model?
>>
>> Paolo
>>
>>
>> On Monday, September 17, 2012 7:21:42 AM UTC+2, mweissen wrote:
>>>
>>> I have read some threads about this error message -  I got it too:
>>>
>>> Version  web2py™ (2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51, 
>>> 30), 'stable')  Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>> 17.
>>> 18.
>>> 19.
>>> 20.
>>> 21.
>>> 22.
>>> 23.
>>> 24.
>>> 25.
>>> 26.
>>> 27.
>>>
>>> Traceback (most recent call last):
>>>   File "/users/www-data/web2py/gluon/**main.py", line 547, in 
>>> wsgibase
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> session._try_store_on_disk(req**uest, response)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**globals.py", line 686, in 
>>> _try_store_on_disk
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> cPickle.dump(dict(self), response.session_file)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/usr/lib/python2.7/copy_reg.**py", line 74, in _reduce_ex
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> getstate = self.__getstate__
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7344, in 
>>> __getattr__
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> self.__allocate()
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7337, in 
>>> __allocate
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> self._record = self._table[int(self)]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7624, in 
>>> __getitem__
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> return self._db(self._id == key).select(limitby=(0,1)).fir**st()
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 8766, in select
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> return adapter.select(self.query,fiel**ds,attributes)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 2094, in select
>>>
>>>
>>>
>>>

[web2py] Re: grid export button

2012-10-22 Thread Paolo Caruccio
For grid export menu I'm happy with below method

In the views/*.html file where is your grid put on top (just below extend 
layout command)  the following code:

{{
w2p_grid_tbl = grid.element('table')
if w2p_grid_tbl:
 export_menu = grid.element('div.w2p_export_menu')
 export_menu_links = export_menu.elements('a')
 export_menu_items = []
 for link in export_menu_links:
 item = LI(link)
 export_menu_items.append(item)
 pass
 export_menu = grid.element('div.w2p_export_menu',replace=None)
 new_export_menu = DIV(
  A( T('Exports'),
 SPAN(_class='caret'),
 _href='#',
 _class='btn dropdown-toggle',
 **{'_data-toggle':"dropdown"}
),
  UL(*export_menu_items,
 _class='dropdown-menu'
),
_class='w2p_export_menu btn-group'
)
pass
}}

In the attached picture you can see how the exports menu is rendered using 
css bootstrap framework.

The method is based on Server-side DOM and parsing (
http://web2py.com/books/default/chapter/29/05#Server-side-DOM-and-parsing) 
and it uses the elements argument "replace" (new beatiful and powerful - in 
my opinion - feature). For reference you could read 
https://groups.google.com/forum/?fromgroups=#!topic/web2py/fbYZXoIOkCY

I hope this will help you.

 

Il giorno lunedì 22 ottobre 2012 17:15:37 UTC+2, Omi Chiba ha scritto:
>
> New export function on grid has many choices but I need to keep the old 
> format. (Export button for csv) because...
>
> - I'm using the gird for users (Maybe this format is good for us but not 
> users.)
> - Current export options layout is not pretty (I prefer button with 
> dropdown list)
> - I don't want users to see hidden columns
>
> Is there any option available for me?
>
>

-- 



<>

[web2py] Re: Multiple domains on the same application

2012-10-22 Thread Niphlod
just assign to domain1.com, domain2.com and domain3.com the same ip address 
(same server) and - if you have a webserver - share the config for all 3 
hostnames. 
Rewrite helps if you need different configs in regard of the domain on the 
same machine, not the other way around (same config for all domains).

On Monday, October 22, 2012 7:48:19 PM UTC+2, Tito Garrido wrote:
>
> Hi Folks!
>
> Is possible to use multiple domains on the same application? I mean, each 
> domain would point to the your controller. I will have similar websites 
> that needs to share the 'upload' directory...
>
> Example:
> domain1.com: init/controler1
> domain2.com: init/controler3
> domain3.com: init/controler3
>
> Thanks!
>
> Tito
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 





Re: [web2py] Re: Multiple domains on the same application

2012-10-22 Thread Tito Garrido
I will test it! Thanks!!!

On Mon, Oct 22, 2012 at 2:59 PM, HittingSmoke wrote:

> I'm pretty sure you can do this with routes.py
>
> routers = dict(
> BASE  = dict(
> domains = {
> 'domain1.com'  : 'app/contoller1',
> 'domain2.com' : 'app/controller2',
> }
> ),
> )
>
>
> On Monday, October 22, 2012 10:48:19 AM UTC-7, Tito Garrido wrote:
>>
>> Hi Folks!
>>
>> Is possible to use multiple domains on the same application? I mean, each
>> domain would point to the your controller. I will have similar websites
>> that needs to share the 'upload' directory...
>>
>> Example:
>> domain1.com: init/controler1
>> domain2.com: init/controler3
>> domain3.com: init/controler3
>>
>> Thanks!
>>
>> Tito
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>  --
>
>
>
>



-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





[web2py] Re: Multiple domains on the same application

2012-10-22 Thread HittingSmoke
I'm pretty sure you can do this with routes.py

routers = dict(
BASE  = dict(
domains = {
'domain1.com'  : 'app/contoller1',
'domain2.com' : 'app/controller2',
}
),
)


On Monday, October 22, 2012 10:48:19 AM UTC-7, Tito Garrido wrote:
>
> Hi Folks!
>
> Is possible to use multiple domains on the same application? I mean, each 
> domain would point to the your controller. I will have similar websites 
> that needs to share the 'upload' directory...
>
> Example:
> domain1.com: init/controler1
> domain2.com: init/controler3
> domain3.com: init/controler3
>
> Thanks!
>
> Tito
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>

-- 





[web2py] Re: Twitter Boostrap Modal form containing SQLForm

2012-10-22 Thread villas
Thanks Chris!  
Good to know the slice works.

On Monday, October 22, 2012 3:50:20 PM UTC+1, c0nstin3 wrote:
>
> Hi,
> Thanks very much for your great help and code slice... it works perfectly! 
> *Brilliant!*
>
> You [*and web2py*] rock, dude! :)
>
> Have a great day,
>
> Kind Regards
> Chris
>
> On Monday, 22 October 2012 00:10:15 UTC+1, villas wrote:
>>
>> I think this is such common requirement,  but took me a long time to get 
>> working because the libraries were not always correct/compatible which was 
>> very confusing for me.  I originally found some code which I adapted and 
>> added a simple spam test,  but I wouldn't really use that technique on a 
>> popular site,  it is too easily compromised.
>>
>> I couldn't get the Bootstrap one working so I used the jQuery one.
>>
>> I made a slice with the code. Hope it works for you.
>>
>> http://www.web2pyslices.com/slice/show/1566/modal-enquiry-form
>>
>>

-- 





[web2py] Multiple domains on the same application

2012-10-22 Thread Tito Garrido
Hi Folks!

Is possible to use multiple domains on the same application? I mean, each
domain would point to the your controller. I will have similar websites
that needs to share the 'upload' directory...

Example:
domain1.com: init/controler1
domain2.com: init/controler3
domain3.com: init/controler3

Thanks!

Tito

-- 

Linux User #387870
.
 _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:___

-- 





Re: [web2py] routes.py and anchor links

2012-10-22 Thread Jonathan Lundell
On 22 Oct 2012, at 9:28 AM, David Sorrentino  wrote:
> I have got some doubts about the use of anchor links and the URL rewriting by 
> means of routes.py.
> 
> This is my routes.py:
> 
> routes_out = (
> ('/myapp/default/$f', '/$f')
> )
> 
> So /myapp/default/just_a_page is rewritten in output like /just_a_page . This 
> works.
> 
> The problem raises when I specify an anchor link in my view, for instance:
> {{=URL(f='just_a_page', anchor="just_an_anchor")}}
> 
> Indeed in this case routes.py does not rewrite the URL, since 
> /myapp/default/just_a_page#just_an_anchor does not match 
> with/myapp/default/$f (understandably).
> 
> So, how could I set up routes.py so that it will rewrite URLs containing 
> anchors?
> 
> Thank you in advance for your help.

Can you use the parametric router? It should handle anchors properly.

Alternatively, try something like:

routes_out = (
('/myapp/default/$f', '/$f')
('/myapp/default/$f/$anything', '/$f/$anything')
)


-- 





Re: [web2py] SQLFORM.grid / appadmin: self-reference question

2012-10-22 Thread lyn2py
Thanks Richard!

On Monday, October 22, 2012 11:41:11 PM UTC+8, Richard wrote:
>
> It is a feature of list:reference... It may be broken for self-referenced 
> table. There was an issue with self-reference in the pass, don't know if it 
> get fixed or not.
>
> You may have a look to pending issue on google code.
>
> Richard
>
> On Mon, Oct 22, 2012 at 11:08 AM, lyn2py  >wrote:
>
>> I have a table that self-references:
>>
>> db.define_table('tags',
>> Field('tag', 'string',length=255,requires=IS_NOT_EMPTY()),
>> Field('description','text'),
>> Field('parent_tags', 'list:reference tags'),
>> format='%(tag)s'
>> )
>>
>> And in appdamin and SQLFORM.grid, I noticed that there is a "+" sign next 
>> to the self-referenced field. I presumed, it may be used to add items to 
>> the field. But when I click on it, nothing happens.
>>
>> Is this a bug? Or what is its intended behavior? Thanks!
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Re: Dropbox Error : to many values to unpack

2012-10-22 Thread hasan alnator
Dear Massimo ,

i got this from the book :

from gluon.contrib.login_methods.dropbox_account import use_dropbox
use_janrain(auth,filename='private/dropbox.key')
mydropbox = auth.settings.login_form


http://web2py.com/books/default/chapter/29/14?search=dropbox#Dropbox-API

Best Regards,


On Mon, Oct 22, 2012 at 7:14 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> You cannot use janrain with dropbox. They are different APIs and use
> different keys. Look into
>
> gluon/contrib/login_methods/dropbox_account.py
>
> for examples
>
>
> On Monday, 22 October 2012 08:11:13 UTC-5, Hassan Alnatour wrote:
>>
>> Dear ALL ,
>>
>> i am trying to work with dropbox API i addedthe file dropbox.key in 
>> app/private and added the keys in it , i added the dropbox module and i am 
>> getting this error , any help ?
>>
>>
>> regards,
>>
>>
>> Traceback (most recent call last):
>>   File "C:\web2py\gluon\restricted.**py", line 209, in restricted
>> exec ccode in environment
>>   File "C:/web2py/applications/**dropbox/models/db.py" 
>> , line 67, in 
>> 
>> use_janrain(auth,filename='**private/dropbox.key')
>>   File "C:\web2py\gluon\contrib\**login_methods\rpx_account.py", line 121, 
>> in use_janrain
>> domain,key = open(path,'r').read().strip().**split(':')
>> ValueError: too many values to unpack
>>
>>  --
>
>
>
>

-- 





[web2py] routes.py and anchor links

2012-10-22 Thread David Sorrentino
Hey there! :)

I have got some doubts about the use of anchor links and the URL rewriting
by means of *routes.py*.

This is my *routes.py*:

routes_out = (
> ('/myapp/default/$f', '/$f')
> )
>

So* **/myapp/default/just_a_page* is rewritten in output like
*/just_a_page*. This works.

The problem raises when I specify an anchor link in my view, for instance:

> {{=URL(f='just_a_page', anchor="just_an_anchor")}}
>

Indeed in this case *routes.py* does not rewrite the URL, since *
**/myapp/default/just_a_page#just_an_anchor
*does not match with */myapp/default/$f* (understandably).

So, how could I set* *up *routes.py* so that it will rewrite URLs
containing anchors?

Thank you in advance for your help.

Cheers,
David

-- 





[web2py] Re: Dropbox Error : to many values to unpack

2012-10-22 Thread Massimo Di Pierro
You cannot use janrain with dropbox. They are different APIs and use 
different keys. Look into 

gluon/contrib/login_methods/dropbox_account.py

for examples


On Monday, 22 October 2012 08:11:13 UTC-5, Hassan Alnatour wrote:
>
> Dear ALL , 
>
> i am trying to work with dropbox API i addedthe file dropbox.key in 
> app/private and added the keys in it , i added the dropbox module and i am 
> getting this error , any help ?
>
>
> regards,
>
>
> Traceback (most recent call last):
>   File "C:\web2py\gluon\restricted.py", line 209, in restricted
> exec ccode in environment
>   File "C:/web2py/applications/dropbox/models/db.py" 
> , line 67, in 
> 
> use_janrain(auth,filename='private/dropbox.key')
>   File "C:\web2py\gluon\contrib\login_methods\rpx_account.py", line 121, in 
> use_janrain
> domain,key = open(path,'r').read().strip().split(':')
> ValueError: too many values to unpack
>
>

-- 





Re: [web2py] SQLFORM.grid / appadmin: self-reference question

2012-10-22 Thread Richard Vézina
It is a feature of list:reference... It may be broken for self-referenced
table. There was an issue with self-reference in the pass, don't know if it
get fixed or not.

You may have a look to pending issue on google code.

Richard

On Mon, Oct 22, 2012 at 11:08 AM, lyn2py  wrote:

> I have a table that self-references:
>
> db.define_table('tags',
> Field('tag', 'string',length=255,requires=IS_NOT_EMPTY()),
> Field('description','text'),
> Field('parent_tags', 'list:reference tags'),
> format='%(tag)s'
> )
>
> And in appdamin and SQLFORM.grid, I noticed that there is a "+" sign next
> to the self-referenced field. I presumed, it may be used to add items to
> the field. But when I click on it, nothing happens.
>
> Is this a bug? Or what is its intended behavior? Thanks!
>
> --
>
>
>
>

-- 





[web2py] grid export button

2012-10-22 Thread Omi Chiba
New export function on grid has many choices but I need to keep the old 
format. (Export button for csv) because...

- I'm using the gird for users (Maybe this format is good for us but not 
users.)
- Current export options layout is not pretty (I prefer button with 
dropdown list)
- I don't want users to see hidden columns

Is there any option available for me?

-- 





[web2py] SQLFORM.grid / appadmin: self-reference question

2012-10-22 Thread lyn2py
I have a table that self-references:

db.define_table('tags',
Field('tag', 'string',length=255,requires=IS_NOT_EMPTY()),
Field('description','text'),
Field('parent_tags', 'list:reference tags'),
format='%(tag)s'
)

And in appdamin and SQLFORM.grid, I noticed that there is a "+" sign next 
to the self-referenced field. I presumed, it may be used to add items to 
the field. But when I click on it, nothing happens.

Is this a bug? Or what is its intended behavior? Thanks!

-- 





[web2py] Auto-completion and the ajax function bug web2py manual (p. 472 )

2012-10-22 Thread martzi
Hi all,
following the example on auto-completion in web2py manual, there seems to 
be a "bug" using the ajax function with parameterized url.
accessing the page normally in my case with 
 (http://127.0.0.1:8000/AjaxApp/default/month_input) works fine.
but  accessing the page with args say 1,  like so =>( 
http://127.0.0.1:8000/AjaxApp/default/month_input/1 ) something weird 
happened.

Please has anyone experienced across the same problem ?

-- 





[web2py] Re: Twitter Boostrap Modal form containing SQLForm

2012-10-22 Thread c0nstin3
Hi,
Thanks very much for your great help and code slice... it works perfectly! *
Brilliant!*

You [*and web2py*] rock, dude! :)

Have a great day,

Kind Regards
Chris

On Monday, 22 October 2012 00:10:15 UTC+1, villas wrote:
>
> I think this is such common requirement,  but took me a long time to get 
> working because the libraries were not always correct/compatible which was 
> very confusing for me.  I originally found some code which I adapted and 
> added a simple spam test,  but I wouldn't really use that technique on a 
> popular site,  it is too easily compromised.
>
> I couldn't get the Bootstrap one working so I used the jQuery one.
>
> I made a slice with the code. Hope it works for you.
>
> http://www.web2pyslices.com/slice/show/1566/modal-enquiry-form
>
>

-- 





Re: [web2py] Help With Dropbox idea

2012-10-22 Thread hasan alnator
I Did this :

in db.py :

from gluon.contrib.login_methods.dropbox_account import DropboxAccount
auth.settings.actions_disabled=['register','change_password','request_reset_password']
auth.settings.login_form =
DropboxAccount(request,key="",secret="..",access_type="dropbox",login_url
= "http://localhost:8000/%s/default/user/login"; % request.application)
if auth.user:
user_dropbox = auth.settings.login_form

in default.py :

def dropbox():
stream = open('localfile.txt','rb')
user_dropbox.put('destfile.txt',stream)
return locals()


but i am getting this error

Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/dropbox/controllers/default.py"
,
line 82, in 
  File "C:\web2py\gluon\globals.py", line 187, in 
self._caller = lambda f: f()
  File "C:/web2py/applications/dropbox/controllers/default.py"
,
line 14, in dropbox
user_dropbox.put('destfile.txt',stream)
  File "C:\web2py\gluon\contrib\login_methods\dropbox_account.py",
line 102, in put
return json.loads(self.client.put_file(filename,file))['bytes']
AttributeError: 'DropboxAccount' object has no attribute 'client'


regards,



On Mon, Oct 22, 2012 at 5:19 PM, Jonathan Lundell wrote:

> On 22 Oct 2012, at 4:48 AM, Hassan Alnatour 
> wrote:
>
> I want to make function that makes a csv file from my database and push it
> to a dropbox folder , any ideas on that ?
>
>
> At the very least create the csv file in a tmp directory and then move it
> atomically to your dropbox folder, so Dropbox (and its clients) don't see a
> partial file.
>
> --
>
>
>
>

-- 





Re: [web2py] Help With Dropbox idea

2012-10-22 Thread Jonathan Lundell
On 22 Oct 2012, at 4:48 AM, Hassan Alnatour  wrote:
> I want to make function that makes a csv file from my database and push it to 
> a dropbox folder , any ideas on that ? 


At the very least create the csv file in a tmp directory and then move it 
atomically to your dropbox folder, so Dropbox (and its clients) don't see a 
partial file.

-- 





[web2py] deploying web2py in mountain lion server with mod_wsgi

2012-10-22 Thread Mobility
Can anybody help me install web2py on a production server running mountain 
lion server? I did manage to deploy it using a reverse proxy but not using 
wsgi. My server configuration is:

Mountain lion 10.8.2
Server 2.1.1
Apache 2.2.22
python 2.7.2

-- 





[web2py] Re: Reloading modules stops working after some time ...

2012-10-22 Thread Donatas Burba
My problem (with appy.pod) still persists in v2.2.1 so I'm locked to 
v2.0.9...

-- 





[web2py] Dropbox Error : to many values to unpack

2012-10-22 Thread Hassan Alnatour


Dear ALL , 

i am trying to work with dropbox API i addedthe file dropbox.key in app/private 
and added the keys in it , i added the dropbox module and i am getting this 
error , any help ?


regards,


Traceback (most recent call last):
  File "C:\web2py\gluon\restricted.py", line 209, in restricted
exec ccode in environment
  File "C:/web2py/applications/dropbox/models/db.py" 
, line 67, in 

use_janrain(auth,filename='private/dropbox.key')
  File "C:\web2py\gluon\contrib\login_methods\rpx_account.py", line 121, in 
use_janrain
domain,key = open(path,'r').read().strip().split(':')
ValueError: too many values to unpack

-- 





[web2py] Re: JS object to web2py controller and back

2012-10-22 Thread RyanTheLeach
Took a surprisingly amount of time(which is why i was asking for help), but 
ended up with a solution in the end.

controller:

def jsontest1():
   import gluon.contrib.simplejson
   session.cart = gluon.contrib.simplejson.loads(request.post_vars.cart)
   return session.cart

def jsontest():
   return dict()
 
def jsontest2():
   return dict(cart=gluon.contrib.simplejson.dumps(session.cart))

view

{{extend 'layout.html'}}

{{=cart}}
   
   Try it

javascript:

function ajaxtest(){
$.ajax({
type: "POST",
url: "/partyworldminh/cart/jsontest1.json",
data: "cart="+JSON.stringify(items)
}).done(function( msg ) { alert(msg);});
}

On Monday, October 22, 2012 4:52:30 PM UTC+10:30, RyanTheLeach wrote:
>
> Anyone have a super simple example of how to go from a javascript object, 
> being sent to web2py via jquery.ajax and being returned and processed?
>
> Everything that I've come across has either not worked, or has been 
> sending simple key value pairs.
>
> All I want to be able to do is send a shopping cart full of products and 
> quantities in to web2py to be stored in the session.

-- 





[web2py] Re: How to check if a given user in logged in an external private python script?

2012-10-22 Thread Niphlod
you must load all the session files, unpickle them and see if there is an 
auth.user key in it.

On Monday, October 22, 2012 12:55:12 PM UTC+2, Saurabh Kumar wrote:
>
> By external python script, I mean a python script run using following 
> command:
>
> python web2py.py -S app_name -M -R applications/app_name/private/script.py
>
> I have to check if the user with a given user_id is 'logged in' inside 
> this script.
>

-- 





[web2py] Re: storing values in session[id].variable

2012-10-22 Thread Annet
When I cause an error these are the values stored:

Variables  global request }>  request.args 
['5']  function 'whoWeAre'  global session }>  

  Context 

locals request session response 
locals
function:
'whoWeAre'
session5:
about_dropdown:
who_we_are
False
/about/whoWeAre/5
what_we_do
False
/about/whatWeDo/5
how_we_work
False
/about/howWeWork/5
where_we_are
False
/about/whereWeAre/5
aboutnav:
True
accountID:
2
address:
addressType:
1
houseNumber:
houseNumberExtension:
locality:
nodeID:
5
postalCode:

street:

type:
WORK
calendar_dropdown:
opening_hours
False
/calendar/openingHours/5
event_list
False
/calendar/eventList/5
timetable
False
/calendar/timetable/5
course_table
False
/calendar/courseTable/5
calendarnav:
True
container:
False
courseTable:
True
customtheme:
None
eventList:
True
googlemaps:
True
hero:
isImage:
True
isLogo:
False
nodeID:
5
url:
nodeID5.jpg
herotext:
None
homepage:
True
howWeWork:
True
id:
5
navbarfixedtop:
False
node:
computedName:
computedSubClass:
1
id:
5
openingHours:
True
pluralID:
2
promounit:
True
relatednames:
True
site_menu:
home
False
/site/index/5
about
False
#
calendar
False
#
sitenav:
True
socialmedia:
True
telecom:
nodeID:
5
telecomTypeID:
1
type:
WORK
value:

nodeID:
5
telecomTypeID:
4
type:
WORK
value:
nodeID:
5
telecomTypeID:
5
type:
WORK
value:
theme:
None
timetable:
True
whatWeDo:
True
whereWeAre:
True
whoWeAre:
True
auth:
None
flash:
None
response_args:
5






So function is 'whoWeAre' session[5] stores whoWeAre is True, why doesn't:

elif session[request.args(0)].function:
return True

work?


Kind regards,

Annet






-- 





[web2py] storing values in session[id].variable

2012-10-22 Thread Annet
In my application lots of nodes use the same controllers and views. I store 
some settings in session[id] where id is the id of the node. Based on 
whether a user has access to a function or not I build a menu and set 
session[id].functionname=True. This is part of the code:

if a.nav.id==ABOUTNAVID:
session[id].site_menu.append([T(a.nav.name),False,'#'])
elif a.nav.id==WHOWEARENAVID:
aboutDropdown(id,a)
session[id].whoWeAre=True
elif a.nav.id==WHATWEDONAVID:
aboutDropdown(id,a)
session[id].whatWeDo=True
elif a.nav.id==HOWWEWORKNAVID:
aboutDropdown(id,a)
session[id].howWeWork=True
elif a.nav.id==WHEREWEARENAVID:
aboutDropdown(id,a) 
session[id].whereWeAre=True 

Now when a visitor request a function, I want the function to first check 
session[request.args(0)].functionname.

def whoWeAre():
if has_access(request.function):


This is the has_access function:

def has_access(function):
if not len(request.args):
redirect(URL('addressbook','router'))
elif not session[request.args(0)]:
redirect(URL('addressbook','router',args=request.args(0)))
elif session[request.args(0)].function:
return True
else:
redirect(URL('addressbook','router',args=request.args(0)))

I wonder whether the has_access function has been written correctly, for 
the result doesn't seem to be consistent.


Kind regards,

Annet

-- 





[web2py] Help With Dropbox idea

2012-10-22 Thread Hassan Alnatour
Dear ALL ,

I want to make function that makes a csv file from my database and push it 
to a dropbox folder , any ideas on that ? 

Best Regards,

-- 





[web2py] Re: Multiprocessing in a controller ?

2012-10-22 Thread Tim Richardson


Thanks. I'll use the scheduler. Using multiprocess seemed like it may be a 
cool solution for the purpose of quickly using an existing python script, 
but the problems seemed to multiply pretty quickly. I ran out of mental 
cores. 

>
>
>

-- 





[web2py] How to check if a given user in logged in an external private python script?

2012-10-22 Thread Saurabh Kumar
By external python script, I mean a python script run using following 
command:

python web2py.py -S app_name -M -R applications/app_name/private/script.py

I have to check if the user with a given user_id is 'logged in' inside this 
script.

-- 





[web2py] Re: Multiprocessing in a controller ?

2012-10-22 Thread Niphlod
it's generally a bad idea. webserver can kill your threads (or processes) 
that are hanging (like when launching a very long process you want to 
communicate with) without notice: they do to allow other requests to be 
served, and they kill zombie processes too.

That's why there's a plethora of outside-band async queue-based managers, 
meant to run outside the scope of the webserver.

Web2py has scheduler.py, but that's just one solution. Feel free to expand 
your searches.

On Monday, October 22, 2012 12:15:34 AM UTC+2, Tim Richardson wrote:
>
> Imagine I have a controller that uses multiprocessing to run something in 
> a different process, and then I want an ajax function that updates the form 
> communicating with the background job with a multiprocessing.Manager() .
> I need to keep track of my manager per session. This is not going to work 
> is it?

-- 





Re: [web2py] Re: manage_groups AD problem

2012-10-22 Thread szimszon
I still have no means to test AD but I welcome all the help I can get :)

Please put a 

print '##%s##' % str(group_row)

or 

logger.warning('##%s##' % str(group_row))

line to the gluon/contrib/login_methods/ldap_auth.py file line 627. Restart 
web2py try and send the printed lines back. It seems to me that AD results 
are in other format than ldap results...

2012. október 20., szombat 13:21:52 UTC+2 időpontban software.ted a 
következőt írta:
>
> Hi, went to the office to try out your suggestion. Honetly the debug 
> process is a little strange to me I had put a break at line with 
> ldap_auth() but the next toggled went to very cryptic code i couldn't 
> follow. 
>
> On the other hand you suggested i try adding allowed_groups...i did 
> that and when i click on the login button am getting a ticket. I have 
> attached the ticket details, am not sure why its complaining about the 
> list being indices when your documentation says the list values for 
> allowed_groups should be str as follows: 
> allowed_groups=['group1','group2','etc']. 
>
> I have also noticed your old post: 
>
> "If there is somebody using ldap_auth with AD please try to test 
> allowed_groups and / or manage_groups as I have no means to test it. 
> And I do not know differences between OpenLdap and AD regarding groups 
> :( 
>
> Tnx." 
>
> You still have not tested the group feature? I am quiet surprised, 
> cause AD is widely used and you guys need to test. From the searches I 
> have done, looks like AD does not work well with web2py as far as 
> groups are concerned. 
>
> I goes I have reached a dead end. 
>
> :< 
>
> Thanks for your help. 
>
> Teddy L. 
>
>
> On Sat, Oct 20, 2012 at 9:52 AM, szimszon > 
> wrote: 
> > 
> > ldap_auth(...as usual...,logging_level='debug') 
> > 
> > 2012. október 20., szombat 9:29:44 UTC+2 időpontban software.ted a 
> > következőt írta: 
> >> 
> >> Whr do I set the log level and see how the code is executing I realy 
> need 
> >> that for debugging. 
> >> 
> >> On Oct 20, 2012 9:20 AM, "szimszon"  wrote: 
> >>> 
> >>> Could you set ldap_auth's logging_level to debug and see (in console) 
> >>> what's happening? Or you could specify allowed_groups=['some group 
> name'] if 
> >>> there a logic error and login  works only with allowed_groups set. 
> >>> 
> >>> Sorry I have no AD to test. With ldap it works. So I need a bit 
> help... 
> >>> 
> >>> 2012. október 20., szombat 7:44:20 UTC+2 időpontban software.ted a 
> >>> következőt írta: 
>  
>  Yes that's one am referring to. The moment I introduce the parameter 
>  manage_groups users fail to login against AD...this is my sample 
> code: 
>  
>  from gluon.contrib.login_methods.ldap_auth import ldap_auth 
>  auth.settings.login_methods = [ldap_auth(mode='ad', manage_groups= 
> True, 
>  bind_dn = 'CN=Admin,DC=example,DC=co,DC= zm', bind_pw = 'ADPASSWORD', 
>  group_dn = 'DC= example,DC=co,DC=zm', group_name_attrib = 'cn', 
>  group_member_attrib = 'member', group_filterstr = 
> 'objectClass=Group', 
>  server='xxx.xxx.xxx.xxx', base_dn='dc=example,dc=co,dc=zm')] 
>  Any reason why group management is not working? Is there another way 
> I 
>  can use AD users and assign rolls to certain users? 
>  
>  Teddy L. 
>  
>  On Oct 19, 2012 8:46 PM, "Massimo Di Pierro"  
>  wrote: 
> > 
> > Are you talking about ldap_auth? 
> > 
> > On Friday, 19 October 2012 02:38:39 UTC-5, software.ted wrote: 
> >> 
> >> I am having trouble with manage_group=True, when I enable it i am 
> >> getting "Invalid Login" but without it logins work. Does AD Group 
> >> Management in web2py work? 
> >> 
> >> Kind regards, 
> > 
> > -- 
> > 
> > 
> > 
> >>> 
> >>> -- 
> >>> 
> >>> 
> >>> 
> > 
> > -- 
> > 
> > 
> > 
>
>
>
> -- 
> ...
>  
>
> Teddy Lubasi Nyambe 
> Opensource Zambia 
> Lusaka, ZAMBIA 
>
> Cell: +260 97 7760473 
> website: http://www.opensource.org.zm 
>
> ~/ 
> Human Knowledge belongs to the world! - AntiTrust 
>
> Man is a tool-using animal. Without tools he is nothing, with tools he 
> is all - Thomas Carlyle 1795-1881 
>
> /~ 
>

-- 





Re: [web2py] Re: ProgrammingError: Cannot operate on a closed database

2012-10-22 Thread Hassan Alnatour

Dear mweissen 

i am having the same problem but on a windows server !?  can you help me  ? 
from where should i start ??

regards,


On Wednesday, September 19, 2012 8:51:23 PM UTC+3, mweissen wrote:
>
> Solved.
> The permission of a lot files have been wrong: 
> I develop an application on a windows system and the target system is a 
> linux machine. Some permissions got wrong values after copying the 
> application files.
>
>
> 2012/9/17 Massimo Di Pierro >
>
>> You error seems to indicate there is a lock object in session. Can you 
>> try check by printing the session.keys() before saving the session?
>>
>>
>> On Monday, 17 September 2012 12:54:54 UTC-5, mweissen wrote:
>>
>>> Yes, I have stored a lot of information in session, but only strings and 
>>> dicts. The application works fine on my development pc (a windows 7 pc). 
>>> The problem arises after I have put the application on the target machine 
>>> (ubuntu with apache2).
>>>
>>> 2012/9/17 Massimo Di Pierro 
>>>
>>> Looks like the problem is that you try pus something in session that is 
 not pickleable.


 On Monday, 17 September 2012 02:59:54 UTC-5, mweissen wrote:

> From the /var/log/apache2/error.log:
>
> [Mon Sep 17 09:39:09 2012] [error] ERROR:web2py:Traceback (most recent 
> call last):
> [Mon Sep 17 09:39:09 2012] [error]   File 
> "/users/www-data/web2py/gluon/main.py", line 547, in wsgibase
> [Mon Sep 17 09:39:09 2012] [error] session._try_store_on_disk(**
> req**uest, response)
> [Mon Sep 17 09:39:09 2012] [error]   File 
> "/users/www-data/web2py/gluon/globals.py", line 686, in 
> _try_store_on_disk
> [Mon Sep 17 09:39:09 2012] [error] cPickle.dump(dict(self), 
> response.session_file)
> [Mon Sep 17 09:39:09 2012] [error]   File "/usr/lib/python2.7/copy_reg.
> **p**y", line 70, in _reduce_ex
> [Mon Sep 17 09:39:09 2012] [error] raise TypeError, "can't pickle 
> %s objects" % base.__name__
> [Mon Sep 17 09:39:09 2012] [error] TypeError: can't pickle lock objects
> [Mon Sep 17 09:39:09 2012] [error]
>
>
> 2012/9/17 Paolo 
>
> Dear all,
>> occasionally, I am getting this error too (with and without 
>> lazy_table)
>> Which OS are you using ?
>> Could you post your db model?
>>
>> Paolo
>>
>>
>> On Monday, September 17, 2012 7:21:42 AM UTC+2, mweissen wrote:
>>>
>>> I have read some threads about this error message -  I got it too:
>>>
>>> Version  web2py™ (2, 0, 9, datetime.datetime(2012, 9, 13, 23, 51, 
>>> 30), 'stable')  Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>> 17.
>>> 18.
>>> 19.
>>> 20.
>>> 21.
>>> 22.
>>> 23.
>>> 24.
>>> 25.
>>> 26.
>>> 27.
>>>
>>> Traceback (most recent call last):
>>>   File "/users/www-data/web2py/gluon/**main.py", line 547, in 
>>> wsgibase
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> session._try_store_on_disk(req**uest, response)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**globals.py", line 686, in 
>>> _try_store_on_disk
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> cPickle.dump(dict(self), response.session_file)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/usr/lib/python2.7/copy_reg.**py", line 74, in _reduce_ex
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> getstate = self.__getstate__
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7344, in 
>>> __getattr__
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> self.__allocate()
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7337, in 
>>> __allocate
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> self._record = self._table[int(self)]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 7624, in 
>>> __getitem__
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> return self._db(self._id == key).select(limitby=(0,1)).fir**st()
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 8766, in select
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> return adapter.select(self.query,fiel**ds,attributes)
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>   File "/users/www-data/web2py/gluon/**dal.py", line 2094, in select
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> return super(SQLiteAd

[web2py] Re: web2py love

2012-10-22 Thread apps in tables

How deep is your love?

-- 





[web2py] Re: appadmin upload from iPhone gives empty record.

2012-10-22 Thread Richard
The request.vars.file turn out to indicate that a file is uploaded from my 
iPhone. Issue solved.

Doing some tests showed me a point to be aware of. Showing the images in a 
HTML page can give  a difference between windows browser (Firefox and 
Chrome) and my iPhone. It turns out that the iPhone browser take into 
account to top and bottom of the picture, Windows browsers do not by 
default. Interesting to know and maybe to try to deal with.

Richard


On Sunday, October 21, 2012 12:37:26 AM UTC+2, Massimo Di Pierro wrote:
>
> Can you somehow log request.vars.file on upload? The issue is to determine 
> whether the file is there or not.
>
> On Saturday, 20 October 2012 12:42:55 UTC-5, Richard wrote:
>>
>> Hi,
>>
>> I want to use Web2Py as much as possible. For a holiday blog I want to 
>> upload photo's from my iPhone using appadmin.
>> From my windows PC this works file. I get a file location and a file 
>> which i can view.
>>
>> But an upload from my iPhone gives no error, a new record is created but 
>> without image.file which must contain a link to the upload photo.
>>
>> I use the easy db definition:
>>
>> db.define_table(
>> 'loc',
>> Field('location'),
>> format = '%(location)s'
>> )
>>
>> db.define_table(
>>'image',
>>Field('loc', 'reference loc'),
>>Field('title', unique=True),
>>Field('file', 'upload'),
>>format = '%(title)s'
>>)
>>
>> Does anybody has a clu?
>>
>> Richard.
>>
>

--