[web2py] Re: gluon/Portlocker.py LockedFile BROKEN!

2015-03-09 Thread danny
i replied from my mailer, which goggle sent to the moderator :-)
here we go again:

sure, e.g:

https://docs.python.org/2.4/lib/bltin-file-objects.html

look for seek:
  
*seek*(
 
*offset*[*, whence*])
  
Set the file's current position, like stdio's fseek(). The *whence* argument 
is optional and defaults to 0 (absolute file positioning); other values are 
1 (seek relative to the current position) and 2 (seek relative to the 
file's end). There is no return value. Note that if the file is opened for 
appending (mode 'a' or 'a+'), any seek() operations will be undone at the 
next write. 
**

If the file is only opened for 
writing in append mode (mode 'a'), this method is essentially a no-op, but 
it remains useful for files opened in append mode with reading enabled 
(mode 'a+'). If the file is opened in text mode (without 'b'), only offsets 
returned by tell() are legal. Use of other offsets causes undefined 
behavior.

Note that not all file objects are seekable.
On Monday, March 9, 2015 at 10:44:29 AM UTC+2, Niphlod wrote:
>
> still don't see any reference in the docs..
>
> On Monday, March 9, 2015 at 8:01:13 AM UTC+1, da...@mail.hebrew.edu wrote:
>>
>> the work around is to set truncate(0).
>>
>>
>> On Sunday, March 8, 2015 at 5:14:14 PM UTC+2, da...@mail.hebrew.edu 
>> wrote:
>>>
>>> hi,
>>> after python 2.7.2, seek(0) on an opened file for append does not seek 
>>> to the begining - read the manual.
>>>
>>> so LockedFile(...) used by languages, is screwing up the language 
>>> translation file.
>>>
>>> I don't understand why the code does a seek(0)/truncate if not opened 
>>> for truncate, maybe it's
>>> a windows issue? It's not working on UNix!
>>>
>>> danny
>>>
>>>

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


[web2py] Re: gluon/Portlocker.py LockedFile BROKEN!

2015-03-09 Thread danny

the docs:

sure, e.g:

https://docs.python.org/2.4/lib/bltin-file-objects.html

look for seek:
  
*seek*(
 
*offset*[*, whence*])
  
Set the file's current position, like stdio's fseek(). The *whence* argument 
is optional and defaults to 0 (absolute file positioning); other values are 
1 (seek relative to the current position) and 2 (seek relative to the 
file's end). There is no return value. Note that if the file is opened for 
appending (mode 'a' or 'a+'), any seek() operations will be undone at the 
next write. 
**

If the file is only opened for 
writing in append mode (mode 'a'), this method is essentially a no-op, but 
it remains useful for files opened in append mode with reading enabled 
(mode 'a+'). If the file is opened in text mode (without 'b'), only offsets 
returned by tell() are legal. Use of other offsets causes undefined 
behavior.

Note that not all file objects are seekable.
On Sunday, March 8, 2015 at 5:14:14 PM UTC+2, da...@mail.hebrew.edu wrote:
>
> hi,
> after python 2.7.2, seek(0) on an opened file for append does not seek to 
> the begining - read the manual.
>
> so LockedFile(...) used by languages, is screwing up the language 
> translation file.
>
> I don't understand why the code does a seek(0)/truncate if not opened for 
> truncate, maybe it's
> a windows issue? It's not working on UNix!
>
> danny
>
>

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


[web2py] Re: gluon/Portlocker.py LockedFile BROKEN!

2015-03-09 Thread danny
the work around is to set truncate(0).


On Sunday, March 8, 2015 at 5:14:14 PM UTC+2, da...@mail.hebrew.edu wrote:
>
> hi,
> after python 2.7.2, seek(0) on an opened file for append does not seek to 
> the begining - read the manual.
>
> so LockedFile(...) used by languages, is screwing up the language 
> translation file.
>
> I don't understand why the code does a seek(0)/truncate if not opened for 
> truncate, maybe it's
> a windows issue? It's not working on UNix!
>
> danny
>
>

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


[web2py] gluon/Portlocker.py LockedFile BROKEN!

2015-03-08 Thread danny
hi,
after python 2.7.2, seek(0) on an opened file for append does not seek to 
the begining - read the manual.

so LockedFile(...) used by languages, is screwing up the language 
translation file.

I don't understand why the code does a seek(0)/truncate if not opened for 
truncate, maybe it's
a windows issue? It's not working on UNix!

danny

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


[web2py] where are Massimo's lesson sources?

2015-02-22 Thread danny
Hi,
I'm watching Massimo's lessons, and was wondering if there are sources for
the applications he is teaching

thanks,
  danny

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


[web2py] Re: user_id is none when session is db

2014-10-14 Thread danny
SOLVED!
I moved the session.connect(...) from the end of my db.py to the top, and 
now it's ok!

thanks,
  danny

On Wednesday, October 15, 2014 8:29:57 AM UTC+3, da...@mail.hebrew.edu 
wrote:
>
>
> I created a new application, changed db.py so that session.connect(…) uses 
> postgres,
>
> created a test user, and all seems ok :-(
>
> so the hunting is still on, what bothers me is that all works ok when 
> session is stored in file!
>
> it could be my pam_auth, but it has been working without a problem for a 
> long time.
>
>
> thanks,
>
> danny
>
> On Tuesday, October 14, 2014 4:46:59 PM UTC+3, Anthony wrote:
>>
>> I cannot reproduce this problem. Could you attach a minimal app the 
>> reproduces the behavior?
>>
>> Anthony
>>
>> On Tuesday, October 14, 2014 9:19:59 AM UTC-4, da...@mail.hebrew.edu 
>> wrote:
>>>
>>> sorry, some correction:
>>>
>>> the value of auth.user is None, auth is an object.
>>>
>>> which explains why auth.is_logged_in() is False even after a successful 
>>> login
>>>
>>> On Tuesday, October 14, 2014 2:25:20 PM UTC+3, Anthony wrote:
>>>>
>>>> What exactly is None (i.e., what do you mean that auth is None)? Is 
>>>> auth defined after connecting the session?
>>>
>>>

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


[web2py] Re: user_id is none when session is db

2014-10-14 Thread danny
 


I created a new application, changed db.py so that session.connect(…) uses 
postgres,

created a test user, and all seems ok :-(

so the hunting is still on, what bothers me is that all works ok when 
session is stored in file!

it could be my pam_auth, but it has been working without a problem for a 
long time.


thanks,

danny

On Tuesday, October 14, 2014 4:46:59 PM UTC+3, Anthony wrote:
>
> I cannot reproduce this problem. Could you attach a minimal app the 
> reproduces the behavior?
>
> Anthony
>
> On Tuesday, October 14, 2014 9:19:59 AM UTC-4, da...@mail.hebrew.edu 
> wrote:
>>
>> sorry, some correction:
>>
>> the value of auth.user is None, auth is an object.
>>
>> which explains why auth.is_logged_in() is False even after a successful 
>> login
>>
>> On Tuesday, October 14, 2014 2:25:20 PM UTC+3, Anthony wrote:
>>>
>>> What exactly is None (i.e., what do you mean that auth is None)? Is auth 
>>> defined after connecting the session?
>>
>>

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


[web2py] Re: user_id is none when session is db

2014-10-14 Thread danny
 

sorry, some correction:

the value of auth.user is None, auth is an object.

which explains why auth.is_logged_in() is False even after a successful 
login

On Tuesday, October 14, 2014 2:25:20 PM UTC+3, Anthony wrote:
>
> What exactly is None (i.e., what do you mean that auth is None)? Is auth 
> defined after connecting the session?

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


[web2py] Re: user_id is none when session is db

2014-10-14 Thread danny
some more info:
 it's the auth storage that fails to be assigned (is none) when session is 
in db, thus
 login succeeds, but in reality it fails since auth is None!

 
On Monday, October 13, 2014 11:42:31 AM UTC+3, da...@mail.hebrew.edu wrote:
>
> hi,
> when session is stored in file, all is ok, but when using db 
> (session.connect(..., db)) after loginin,
> the user_id is None. (in glueon/tools.py)
> btw, I'm using the latest version of web2py
>
> cheers,
> danny
>
>
>
>

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


[web2py] user_id is none when session is db

2014-10-13 Thread danny
hi,
when session is stored in file, all is ok, but when using db 
(session.connect(..., db)) after loginin,
the user_id is None. (in glueon/tools.py)
btw, I'm using the latest version of web2py

cheers,
danny



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


[web2py] form in hebrew

2014-02-01 Thread danny
so far I have great success using web2py and forms, but
my knowledge of html/css etc tends to zero, so is there a simple way to
have a form in hebrew? i.e 
  hebrew input data : hebrew field name
thanks,
  danny

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


[web2py] pam authentication works?

2013-04-19 Thread danny
I must be doing something wrong, but just following the manual instructions
for PAM authentication I get
 ... global name 'username' not defined
even before I try to login.
changing
auth.settings.login_methods.append(pam_auth() )
to
   auth.settings.login_methods.append(pam_auth)
solved that, then  some more changes in 
gluon/contrib/login_methods/pam_auth.py
finally got it working.

so what gives?
cheers,
   danny



-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: parent child tree query logic

2013-03-11 Thread danny
Perhaps you can try other methods to model parent-child relationship? 

These are related to Closure Table but also talk about other methods:

http://stackoverflow.com/questions/192220/what-is-the-most-efficient-elegant-way-to-parse-a-flat-table-into-a-tree
http://dirtsimple.org/2010/11/simplest-way-to-do-tree-based-queries.html
http://karwin.blogspot.co.uk/2010/03/rendering-trees-with-closure-tables.html

Storing Hierarchical Data in a Database (Adjacency List, Modified Preorder 
Tree Traversal and more reading materials at the end of the article)
http://www.sitepoint.com/hierarchical-data-database/ 

Adjacency List, Materialized Path, Nested Set and Closure Table
http://www.slideshare.net/billkarwin/models-for-hierarchical-data 

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

On Monday, 4 March 2013 22:08:49 UTC, 黄祥 wrote:
>
> hi, 
>
> i want to show parent child tree using table that have self-reference. 
> actually i've tried the self-reference query, but the result is not i 
> expected, is there any idea for this?
>
> for example:
> *db.py*
> db.define_table('category',
> Field('category', length=10, notnull=True, unique=True),
> Field('parent', 'reference category'),
> format='%(category)s')
>
> db.category.parent.requires=IS_EMPTY_OR(IS_IN_DB(db, 'category.category'))
>
> db.category.bulk_insert([{'category' : 'Monitor'}, 
>  {'category' : 'Keyboard'},
>  {'category' : 'Monitor LCD', 'parent' : '1'}, 
>  {'category' : 'Monitor LED', 'parent' : '1'}, 
>  {'category' : 'Keyboard Cable', 'parent' : '2'}, 
>  {'category' : 'Keyboard Gaming', 'parent' : '2'}, 
>  {'category' : 'Keyboard Wireless', 'parent' : 
> '2'}])
>
> *output i expected *
> Keyboard
> - Keyboard Cable
> - Keyboard Gaming
> - Keyboard Wireless
> Monitor
> - Monitor LCD
> - Monitor LED
>
> thank you so much in advance
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: session.flash is None when manually logging out

2012-03-06 Thread danny
Just found the solution. Looking at the source of auth.logout() at 
http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#Auth.logout,
 
there is a line here: 


current 
<http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>.session
 
<http://web2py.com/examples/static/epydoc/web2py.gluon.tools-pysrc.html#>.flash 
= self.messages.logged_out 


which looks like the cause of session.flash being assigned None.

On chapter 9 of the book (http://web2py.com/books/default/chapter/29/9), 
there is a bunch of auth.messages that can be customized, such as the one 
for logging out:

auth.messages.logged_out = T('You are logged out.')


Now session.flash (actully response.flash after the redirect) will have 
whatever message I set. 


On Wednesday, 7 March 2012 00:02:08 UTC, danny wrote:
>
> Hello. I'm trying to customize the login and register forms as follows:
>
>- user() function does not return auth(), instead display two forms 
>separately like this:
>
>   {{if not auth.is_logged_in():}}
>   {{login_form = auth.login()}}
>   {{=login_form.custom.begin}}
>   ...
>   {{=login_form.custom.submit}}
>   {{=login_form.custom.end}}
>
>   {{reg_form = auth.register()}}
>   {{=reg_form.custom.begin}}
>   ...
>   {{=reg_form.custom.submit}}
>   {{=reg_form.custom.end}}
>   {{pass}}
>
>- Inside user() function it logs the user out manually when "http
>://.../[app]/default/user/logout" is requested:
>
> if request.args(0) == 'logout':
> session.flash = T('You are logged out.')
> auth.logout()
>
> Everything works except session.flash is wiped clean when auth.logout() 
> automatically redirects to default/index. How can I keep session.flash 
> after redirect? Thanks.
>


[web2py] session.flash is None when manually logging out

2012-03-06 Thread danny
Hello. I'm trying to customize the login and register forms as follows:

   - user() function does not return auth(), instead display two forms 
   separately like this:

  {{if not auth.is_logged_in():}}
  {{login_form = auth.login()}}
  {{=login_form.custom.begin}}
  ...
  {{=login_form.custom.submit}}
  {{=login_form.custom.end}}

  {{reg_form = auth.register()}}
  {{=reg_form.custom.begin}}
  ...
  {{=reg_form.custom.submit}}
  {{=reg_form.custom.end}}
  {{pass}}

   - Inside user() function it logs the user out manually when "http://.../[
   app]/default/user/logout" is requested:
   
if request.args(0) == 'logout':
session.flash = T('You are logged out.')
auth.logout()

Everything works except session.flash is wiped clean when auth.logout() 
automatically redirects to default/index. How can I keep session.flash 
after redirect? Thanks.


[web2py] Re: 'web2py.js' and 'web2py_ajax.js': Which one to use?

2011-12-19 Thread danny
Gotcha. Thanks! b

On Dec 20, 4:24 am, Anthony  wrote:
> We just renamed web2py_ajax.js to web2py.js (since it includes some JS code
> not related to Ajax). The old file is no longer included, but if you just
> unzipped the new folders over the old, it wouldn't remove the old file. You
> can delete it. Note, we didn't change the name of web2py_ajax.html in the
> views folder because that would have created more difficulties with
> backward compatibility of layout plugins.
>
> Anthony
>
>
>
>
>
>
>
> On Monday, December 19, 2011 9:41:28 PM UTC-5, danny wrote:
>
> > Hi, in the lastest version of web2py (can't remember if this is the
> > case for older versions), there are two files that are nearly
> > identical in the default applications (admin, examples, welcome) js
> > folder: 'web2py.js' and 'web2py_ajax.js'.
>
> > It looks like 'web2py.js' is the newer of the two, should I just
> > discard 'web2py_ajax.js' if my project doesn't depend on it? Or is
> > there some web2py code that needs it?
>
> > Dan


[web2py] 'web2py.js' and 'web2py_ajax.js': Which one to use?

2011-12-19 Thread danny
Hi, in the lastest version of web2py (can't remember if this is the
case for older versions), there are two files that are nearly
identical in the default applications (admin, examples, welcome) js
folder: 'web2py.js' and 'web2py_ajax.js'.

It looks like 'web2py.js' is the newer of the two, should I just
discard 'web2py_ajax.js' if my project doesn't depend on it? Or is
there some web2py code that needs it?

Dan