Re: [web2py] Drill-down menu with PostgreSQL

2015-02-12 Thread Louis Amon
I haven’t timed the queries but there’s way more than 4 queries to be done.

For instance if I build a drill-down to zoom in on my city (Bordeaux), I would 
need to build something like this :

Aquitaine (administrative_area_level_1)
Gironde (administrative_area_level_2)
Bordeaux (locality)
Talence
etc.

So to build the whole tree I’d need to do nested loops over the first two 
fields (administrative_area_level_1  administrative_area_level_2).
Assuming there’s N administrative_area_level_1 and M 
administrative_area_level_2, I’d need N*M queries to list all localities.

That seems a bit brutish.


I’ve read a bit about nested_queries in web2py but there isn’t much to be 
found. Is it a deprecated mechanism ?

Should I use rows.find()  rows.sort() then ?


 Le 11 févr. 2015 à 20:28, Niphlod niph...@gmail.com a écrit :
 
 did you actually timed the queries ? without knowing the cardinality of the 
 sets, it's pretty impossible to say that a single big-query will be more 
 efficient than 4 on small subsets.
 
 -- 
 Resources:
 - http://web2py.com http://web2py.com/
 - http://web2py.com/book http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py http://github.com/web2py/web2py (Source 
 code)
 - https://code.google.com/p/web2py/issues/list 
 https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to a topic in the Google 
 Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/yF1UHKQqseI/unsubscribe 
 https://groups.google.com/d/topic/web2py/yF1UHKQqseI/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+unsubscr...@googlegroups.com 
 mailto:web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout 
 https://groups.google.com/d/optout.

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


Re: [web2py] Re: Adding entry to the printed book index

2015-02-12 Thread Niphlod
where ?!?!?!

On Thursday, February 12, 2015 at 8:46:48 AM UTC+1, Tom Campbell wrote:

 Stuff like this:

 Between Web Services and websockets I'd put web2py_ajax_component

 Between load and Lotus Notes I'd put locals()

 Between Expression and extent I'd put extend (or insert {{extend}} at 
 the beginning?)


 On Wed, Feb 11, 2015 at 11:30 PM, Niphlod nip...@gmail.com javascript: 
 wrote:

 please give an example of what you're trying to add ^_^


 On Wednesday, February 11, 2015 at 11:33:04 PM UTC+1, Tom Campbell wrote:

 I'd like to add terms to the book's index. Looked at the book source 
 https://github.com/mdipierro/web2py-book/tree/master/sources on 
 github but couldn't figure out where that would happen so I could issue a 
 pull request. Can someone give me a brief description of where I'd find it? 
 Thanks!

  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to a topic in the 
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/oCMlpKs5T3c/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




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


[web2py] Force authentication to whole app

2015-02-12 Thread mcamel
Hello,

You can use @auth* decorators to force authentication to single functions, 
but how you can force authentication to your whole application?.

I use this, just after defining auth:

if not auth.is_logged_in():
# avoid infinite recursion
if request.url != auth.settings.login_url:
# after authentication go to the intended url
redirect(auth.settings.login_url + '?_next=' + request.env.
request_uri)

Any better aproach?.

You can also exclude certain controllers and/or functions:

if not auth.is_logged_in():
if request.controller != 'util' and request.function != 
'change_language':
# avoid infinite recursion
if request.url != auth.settings.login_url:
# after authentication go to the intended url
redirect(auth.settings.login_url + '?_next=' + request.env.
request_uri)

Regards.


-- 
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: auth_user table referenced table

2015-02-12 Thread mcamel
Hi,

It seems wizard is returning id=0 instead of the actual organization id. 
Try removing the wizard from extra fields to guess more.

Just in case, you can try this other syntax:
   
 auth.settings.register_onvalidation.append(lambda form: add_organization(
form))


Regards.


El jueves, 12 de febrero de 2015, 10:18:46 (UTC+1), Yebach escribió:

 Hello

 I have a question regarding adding extra fields to auth_user table 

 now I saw a couple of posts but none answers my question

 I have a table organization. On user registration user adds organization 
 name in form. this value should be inserted into table organization and id 
 of the record into auth_user.organization field. 

 Also some other default values should be inserted into another config 
 table.
 I had this working now I am getting an error 
 class 'psycopg2.IntegrityError' insert or update on table auth_user 
 violates foreign key constraint auth_user_organization_fkey DETAIL: Key 
 (organization)=(0) is not present in table organizations.

 my db.py code

 db.define_table('organizations',
 Field('id',type='id'),
 Field('o_daten', type='datetime',default=request.now),
 Field('o_dateu', type='datetime',default=request.now),
 Field('o_status',type='integer' ),
 Field('o_code',type='string', length = 64 ),
 Field('o_name',type='string', label= T('Organization name'), length = 
 256),
 Field('o_telnumber',type='string',label= T('Telephone number'), length 
 = 64 ),
 Field('o_faxnumber',type='string',label= T('Fax Nb.'), length = 64 ),
 Field('o_street',type='string',label= T('Street'), length = 64 ),
 Field('o_post',type='string',label= T('Post'), length = 64 ),
 Field('o_city',type='string',label= T('City'), length = 64 ),
 Field('o_state',type='string',label= T('State'), length = 64 ),
 Field('o_country',type='string',label= T('Country'), length = 64 ),
 Field('o_TaxNumber',type='string',label= T('Tax number'), length = 64 
 ),
 Field('o_rootid',type='integer' ),
 Field('o_parentid',type='integer' ),
 Field('o_levelid',type='integer'), 
 Field('o_positionx',type='string', length = 64 ),
 Field('o_positiony',type='string', length = 64 ),
 Field('o_note',label= 'Note',type = 'text'),
 migrate=settings.migrate
 )



 then extra field, autocomplete is not really necessary

 auth.settings.extra_fields['auth_user'] = [ Field('organization', 
 'reference organizations', 
   
 widget=SQLFORM.widgets.autocomplete(request, db.organizations.o_name, 
 id_field=db.organizations.id),
label = 
 T('Organization'))]   


 my function to add organization and rows in config table

 def add_organization(form):
 
 Always adds new organization

 

 #if not form.vars.organization:
# print form.vars ,form.vars
 ret = 
 db.organizations.validate_and_insert(o_name=form.vars._autocomplete_organization_o_name_aux)
 
  
 if ret.errors:
 form.errors.organizations = ret.errors['name']
 else:

 org = ret.id
 
 Dodamo podatke v config tabelo ko se kreira nova organizacija
 holiday_duration1480portalDefault trajanje praznika
 vacation_duration1480portalDefault trajanje dopusta
 holiday_color1008000portaltemno zelena
 vacation_color100ff00portalsvetlo zelena
 
 db.config.insert(co_code = holiday_duration, co_value = '420', 
 co_organisation = org, co_note = 'Default trajanje praznika')
 db.config.insert(co_code = vacation_duration, co_value = '480', 
 co_organisation = org , co_note = 'Default trajanje dopusta')   
  
 db.config.insert(co_code = holiday_color, co_value = '008000 ', 
 co_organisation = org, co_note = 'Default barva holiday temno zelena') 
 db.config.insert(co_code = vacation_color, co_value = '00ff00 ', 
 co_organisation = org, co_note = 'Default barva vacation svetlo zelena')
 db.config.insert(co_code = minimum_time_period, co_value = '15 
 ', co_organisation = org, co_note = 'Default vrednost časovne periode')
 
 
 #if not form.vars.organizations:
 #print form.vars._autocomplete_organizations_o_name_aux
 org_name = form.vars._autocomplete_organizations_o_name_aux
 ret = db.organizations.insert(o_name = org_name)


 and at the end 

 auth.settings.register_onvalidation = add_organization

 ## create all tables needed by auth if not custom tables
 auth.define_tables(username=False, signature=False)




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

Re: [web2py] Drill-down menu with PostgreSQL

2015-02-12 Thread Niphlod
if your model is a single table with 4 fields, what's the expected 
resultset ? a nested dict ? if yes, no queries needed, just python.

BTW: a webpage holding 200 locations and requiring 800 queries is not a 
webpage a user would need. 
In other words, what's the maximum number of leaves you want to prefetch ?


-- 
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: Adding entry to the printed book index

2015-02-12 Thread Niphlod
ok... let me rephrase.. where is this stuff on the live version 
on http://web2py.com/book ?

On Thursday, February 12, 2015 at 9:44:09 AM UTC+1, Tom Campbell wrote:

 To the printed book index.


-- 
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: Force authentication to whole app

2015-02-12 Thread mcamel
I basically agree you. I use auth decorators with my functions.

This is just an extra security mechanism, set once in one single place. 
Then you forget about it. It only has sense in some kind of applications.

It could be used instead of auth decorators only in extremelly simple apps 
where you have access to all or nothing.

Regards.


El jueves, 12 de febrero de 2015, 12:34:08 (UTC+1), Leonel Câmara escribió:

 I think the first one (with more exceptions for register, lost password, 
 etc) is an acceptable solution.

 However, when you start making more exceptions then it just starts being 
 messy, unreadable, and I would just start decorating my controller 
 functions (all of them if necessary). That's why it's a decorator so you 
 only put it where it's needed. I don't want to parse a bunch of complicated 
 if conditions in a model file to know if a function in a controller 
 (another file) requires login, it's high cognitive load I don't want in my 
 code.





-- 
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: Force authentication to whole app

2015-02-12 Thread Leonel Câmara
I think the first one (with more exceptions for register, lost password, 
etc) is an acceptable solution.

However, when you start making more exceptions then it just starts being 
messy, unreadable, and I would just start decorating my controller 
functions (all of them if necessary). That's why it's a decorator so you 
only put it where it's needed. I don't want to parse a bunch of complicated 
if conditions in a model file to know if a function in a controller 
(another file) requires login, it's high cognitive load I don't want in my 
code.



-- 
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: Absolute beginner unable to get started

2015-02-12 Thread Massimo Di Pierro
Could this be a permission issue? which user owns the files? is that the 
same user running web2py?

On Saturday, 7 February 2015 08:59:31 UTC-6, MihaW wrote:


 I have installed version w2p 2.9.12 with Python 2.7.6 - on 127.0.0.1 with 
 FF browser. O/s is W7. Example works! But attempts to edit any file at all 
 result in this error. type 'exceptions.IOError'(could not get source 
 code. Very basic mistake on my part? Advice much appreciated!



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


Re: [web2py] Re: Status of workflow functionality

2015-02-12 Thread Richard Vézina
Anyone know if SpiffWorflow is fonded in any way? Is it backed by big
player?

Richard

On Tue, Mar 12, 2013 at 10:25 AM, dlypka dly...@gmail.com wrote:

 Workflow typically stores its state in very complex sql tables.
 If something goes wrong the tables are easily corrupted and then it is
 very hard to fix. (brittle)
 Also if the table design evolves, it is hard to migrate.
 This is my experience with Microsoft Workflow for Windows.

 I believe an entity database will help when it becomes more feasible.

 On Tuesday, March 12, 2013 5:15:58 AM UTC-5, Ramos wrote:

 If i knew howto and have time i would create a workflow as a service.
 This  way i centralize all my rules for every app in a single app.
 If i have 40 apps in my company it would be easy to manage all rules from
 all apps.

 Is this a good way to go?



 2013/3/12 Cliff Kachinske cjk...@gmail.com

 Workflow is not a winning proposition.  If you're working with a small
 business they can't afford the t time it takes to do a decent job.  If it's
 a large company they can afford a big time solution with all the bells and
 whistles.

 It's too ready to get tied up in the rocket science that the full time
 workflow specialists have created.

 --

 ---
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



  --

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




-- 
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: BLOB fields in MSSQL Server

2015-02-12 Thread Jose



 this model is correctly tied to the underlying structure (and web2py 
 conventions). Read my previous post on TEXTSIZE setting throughout your 
 middlewares. 


OK, I'm going to try.
Thank You 

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


[web2py] Re: Absolute beginner unable to get started

2015-02-12 Thread Antonio Salazar
Are you able to edit and save despite that error?

I use the binary of v2.9.12 on Windows 7 and it creates an error ticket 
each minute while editing, but I'm still able to edit and save normally.
The bug is already solved, probably to be included in the next version: 
https://github.com/web2py/web2py/issues/779

El sábado, 7 de febrero de 2015, 8:59:31 (UTC-6), MihaW escribió:


 I have installed version w2p 2.9.12 with Python 2.7.6 - on 127.0.0.1 with 
 FF browser. O/s is W7. Example works! But attempts to edit any file at all 
 result in this error. type 'exceptions.IOError'(could not get source 
 code. Very basic mistake on my part? Advice much appreciated!



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


[web2py] Re: Force authentication to whole app

2015-02-12 Thread Tom Campbell


 To take advantage of the decorators at a file level, you can also do this 
 at the top level of a file:

 auth.requires_login()(lambda: None)()

 The decorators ultimately call auth.requires, which itself returns a 
 decorator. The above passes a dummy function to that decorator and then 
 simply calls it. Note, you don't prepend with @ in this case, as you are 
 not decorating a Python function.

 I think that's brilliant... but I don't quite understand. Without the 
decorators how to the functions in the file get forced to go through 
auth.requires_login()? 

-- 
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: BLOB fields in MSSQL Server

2015-02-12 Thread Jose
SOLVED.

I changed the text size of the connection, the configuration of FreeTDS (
freetds.conf).
I tried with large files and it works great

Thank you very much for the help

-- 
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] Infinite redirect when using ajax callback and a site parameter

2015-02-12 Thread Christian
Hi,

I've observed an unexpected behavior when I link to the index site of the 
default controller using a site parameter: index.html*/SOMEPARAMETER*
Then, the index.html is rendered first showing the correct SOMEPARAMETER 
but starts to redirect to itself infinitely (You will see that the session 
counter increases) and - very strange - the name of the ajax callback 
function newscb becomes the site parameter of the index.html site.

I'm not sure if this is a bug or I misunderstood the ajax - function. You 
can simply reproduce the issue setting up a new application in web2py 
2.9.12 (the issue also occurred in the previous version) using the 
following controller functions and the index.html view. 

Thanks a lot for your time!
Best,
Christian

--

[default.py]
def newscb():
return DIV('TESTNEWS')

def index():
session.counter = (session.counter or 0) + 1
param = request.args(0)
return dict(param = param)

[index.html]
{{extend 'layout.html'}}
h1  Hello World! /h1
h2  Site parameter: {{=param}} /h2
h2  Counter: {{=session.counter}} /h2
div id='text' News Section /div

script
var handler = function() {
ajax('newscb', [], 'text');
}
$(document).ready(handler);
/script

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


Re: [web2py] Re: https only on admin

2015-02-12 Thread Ariya Owam-aram
My case I just  copy default-both.conf (attached in previous post) to 
/etc/apache2/sites-enabled/ 
and restart apache. It work as aspect after done that.
thank you for sharing..  :)

เมื่อ วันพุธที่ 11 กุมภาพันธ์ ค.ศ. 2015 8 นาฬิกา 30 นาที 12 วินาที UTC+7, 
tim spear เขียนว่า:

 I tried similar but then http: didn't work because Apache didn't know to 
 send the requests to web2py. I found the 
 http://stackoverflow.com/questions/28116754/how-can-i-make-part-of-the-website-not-use-https-in-web2py
  
 solution got http to work while keeping admin on https though I was 
 changing things without understanding them very well and hope I have not 
 broken something else.

 On Tue, Feb 10, 2015 at 7:02 AM, Ariya Owam-aram write...@gmail.com 
 javascript: wrote:

 HI Juozas Masiulis 

 In /etc/apache2/sites-enabled/default.conf please chenge rewriterule as 
 follows.

 RewriteEngine On

   RewriteCond %{HTTPS} !=on

   RewriteRule ^/(admin/.*) https://%{SERVER_NAME}/$1 [R,L]

 Hope it wil help



 เมื่อ วันพุธที่ 4 กุมภาพันธ์ ค.ศ. 2015 3 นาฬิกา 48 นาที 21 วินาที UTC+7, 
 Juozas Masiulis เขียนว่า:

 For certain reasons I could not use https for my entire website. I load 
 content from external domains through javascript, which I do not controll, 
 and those scripts get blocked by the browser. I would like to use https 
 only on admin, and I can get apache to redirect only admin to https  by 
 using this http://pastebin.com/raw.php?i=Hkz9YqnH config 

 The redirection seems to work correctly, but then I can't acces admin 
 interface, because I am getting an exception , which I could read only by 
 changing this back to default config. 

 Traceback (most recent call last):
 File /var/www/web2py/gluon/main.py, line 435, in wsgibase
 session.connect(request, response)
 File /var/www/web2py/gluon/globals.py, line 931, in connect
 session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
 TypeError: 'NoneType' object is not callable


 926.
 927.
 928.
 929.
 930.
 931.

 932.
 933.
 934.
 935.

 response.cookies[response.session_id_name]['path'] = '/'
 if cookie_expires:
 response.cookies[response.session_id_name]['expires'] = \
 cookie_expires.strftime(FMT)

 session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)

 response.session_hash = hashlib.md5(session_pickled).hexdigest()

 if self.flash:
 (response.flash, self.flash) = (self.flash, None)

 Function argument list

 (self=Storage {}, request=Storage {'_vars': None, 'function': 'index', 
 'c...'folder': '/var/www/web2py/applications/admin/'}, response=Storage 
 {'body': cStringIO.StringO object at 0..._caller': function lambda at 
 0x7f0dbcfb3050}, db=None, tablename='web2py_session', masterapp='admin', 
 migrate=True, separate=None, check_client=False, cookie_key=None, 
 cookie_expires=None, compression_level=None)

  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to a topic in the 
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/bmVICJOMpXM/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




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


[web2py] web2py session error: type 'exceptions.TypeError'('NoneType' object is not callable)

2015-02-12 Thread Jason Lee
I am storing the session data in a database.

I am using the latest web2py.

I have deleted everything, reinstalled fresh, deleted the database and 
rebuilt it and I still get this error.

The error occurs when I reboot the system.  I can fix it by restarting 
apache2 service once the server has rebooted.


I have a number of serverrs doing this.  It only started when I upgraded.

Error details;

Traceback (most recent call last):
  File /usr/share/www-data/web2py/gluon/main.py, line 435, in wsgibase
session.connect(request, response)
  File /usr/share/www-data/web2py/gluon/globals.py, line 934, in connect
session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
TypeError: 'NoneType' object is not callable


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


Re: [web2py] Re: Status of workflow functionality

2015-02-12 Thread Anthony
No commits for the past year.

On Thursday, February 12, 2015 at 4:41:12 PM UTC-5, Richard wrote:

 Anyone know if SpiffWorflow is fonded in any way? Is it backed by big 
 player?

 Richard

 On Tue, Mar 12, 2013 at 10:25 AM, dlypka dly...@gmail.com wrote:

 Workflow typically stores its state in very complex sql tables.
 If something goes wrong the tables are easily corrupted and then it is 
 very hard to fix. (brittle)
 Also if the table design evolves, it is hard to migrate.
 This is my experience with Microsoft Workflow for Windows.

 I believe an entity database will help when it becomes more feasible.

 On Tuesday, March 12, 2013 5:15:58 AM UTC-5, Ramos wrote:

 If i knew howto and have time i would create a workflow as a service.
 This  way i centralize all my rules for every app in a single app.
 If i have 40 apps in my company it would be easy to manage all rules 
 from all apps.

 Is this a good way to go?



 2013/3/12 Cliff Kachinske cjk...@gmail.com

 Workflow is not a winning proposition.  If you're working with a small 
 business they can't afford the t time it takes to do a decent job.  If 
 it's 
 a large company they can afford a big time solution with all the bells and 
 whistles.

 It's too ready to get tied up in the rocket science that the full time 
 workflow specialists have created.

 --

 ---
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



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




-- 
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: can you execute a command within grid lambda without leaving the function?

2015-02-12 Thread Anthony
The body of a links item is HTML that will get inserted in the grid for 
that row. The function (which doesn't have to be a lambda) is called when 
the grid is generated. It sounds like maybe you instead want something to 
happen when the link is clicked. Can you explain what exactly you are 
trying to do?

On Thursday, February 12, 2015 at 8:07:21 PM UTC-5, Alex Glaros wrote:

 do you need to have a URL redirect in order to have a grid lambda do 
 something?

 can you do anything within the grid lambda itself?

 E.g.

 potentialEmailRecipientsQuery = ((auth.user_id == 
 db.VerifiedConnection.personID)  (db.auth_user.id == 
 db.VerifiedConnection.connectedTo))
 arglist=[]
 grid = SQLFORM.grid(potentialEmailRecipientsQuery,  links = 
 [dict(header='Choose this message recipient',  body=lambda row: 
 A('add',_class=btn, arglist.append(row.id]) ## instead of URL 
 redirect, trying to append new value within the lambda

 all examples I've seen redirect to other URL to do the processing.  I'd 
 like to stay within function in order to build email recipient list into 
 arglist.

 above errors with non-keyword arg after keyword arg

 thanks

 Alex Glaros


-- 
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] can you execute a command within grid lambda without leaving the function?

2015-02-12 Thread Alex Glaros
do you need to have a URL redirect in order to have a grid lambda do 
something?

can you do anything within the grid lambda itself?

E.g.

potentialEmailRecipientsQuery = ((auth.user_id == 
db.VerifiedConnection.personID)  (db.auth_user.id == 
db.VerifiedConnection.connectedTo))
arglist=[]
grid = SQLFORM.grid(potentialEmailRecipientsQuery,  links = 
[dict(header='Choose this message recipient',  body=lambda row: 
A('add',_class=btn, arglist.append(row.id]) ## instead of URL 
redirect, trying to append new value within the lambda

all examples I've seen redirect to other URL to do the processing.  I'd 
like to stay within function in order to build email recipient list into 
arglist.

above errors with non-keyword arg after keyword arg

thanks

Alex Glaros

-- 
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: BLOB fields in MSSQL Server

2015-02-12 Thread Niphlod
no problem. mssql is to blame for some things, but this is definitely not 
one of them ^_^

On Thursday, February 12, 2015 at 10:38:55 PM UTC+1, Jose wrote:

 SOLVED.

 I changed the text size of the connection, the configuration of FreeTDS 
 (freetds.conf).
 I tried with large files and it works great

 Thank you very much for the help


-- 
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: Force authentication to whole app

2015-02-12 Thread Anthony
A decorator is just a special type of function that takes a callable and 
returns another callable. You typically use it via the @ syntax, but you 
don't have to use it that way.

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

is equivalent to:

def myfunc():
return dict()
myfunc = auth.requires_login()(myfunc)

You are simply passing myfunc to a function and getting back a new function.

In the case of auth.requires_login(), we don't really have a function to 
decorate, so we just pass in a dummy function (i.e., lambda: None). What we 
really want is for auth.requires_login() to execute its redirect logic in 
case the user isn't logged in. Otherwise, it should just do nothing and 
move on.

Anthony

On Thursday, February 12, 2015 at 4:29:42 PM UTC-5, Tom Campbell wrote:

 To take advantage of the decorators at a file level, you can also do this 
 at the top level of a file:

 auth.requires_login()(lambda: None)()

 The decorators ultimately call auth.requires, which itself returns a 
 decorator. The above passes a dummy function to that decorator and then 
 simply calls it. Note, you don't prepend with @ in this case, as you are 
 not decorating a Python function.

 I think that's brilliant... but I don't quite understand. Without the 
 decorators how to the functions in the file get forced to go through 
 auth.requires_login()? 


-- 
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: Infinite redirect when using ajax callback and a site parameter

2015-02-12 Thread Leonel Câmara
Hey,

The url is wrong so web2py thinks you're calling index (the default 
function) with a 'newscb' request.args(0).

It should be

var handler = function() {
ajax({{=URL('default', 'newscb')}}, [], 'text');
}


Also consider using the LOAD helper for this usage.

-- 
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: Adding entry to the printed book index

2015-02-12 Thread Tom Campbell
To the printed book index.

-- 
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] auth_user table referenced table

2015-02-12 Thread Yebach
Hello

I have a question regarding adding extra fields to auth_user table 

now I saw a couple of posts but none answers my question

I have a table organization. On user registration user adds organization 
name in form. this value should be inserted into table organization and id 
of the record into auth_user.organization field. 

Also some other default values should be inserted into another config table.
I had this working now I am getting an error 
class 'psycopg2.IntegrityError' insert or update on table auth_user 
violates foreign key constraint auth_user_organization_fkey DETAIL: Key 
(organization)=(0) is not present in table organizations.

my db.py code

db.define_table('organizations',
Field('id',type='id'),
Field('o_daten', type='datetime',default=request.now),
Field('o_dateu', type='datetime',default=request.now),
Field('o_status',type='integer' ),
Field('o_code',type='string', length = 64 ),
Field('o_name',type='string', label= T('Organization name'), length = 
256),
Field('o_telnumber',type='string',label= T('Telephone number'), length 
= 64 ),
Field('o_faxnumber',type='string',label= T('Fax Nb.'), length = 64 ),
Field('o_street',type='string',label= T('Street'), length = 64 ),
Field('o_post',type='string',label= T('Post'), length = 64 ),
Field('o_city',type='string',label= T('City'), length = 64 ),
Field('o_state',type='string',label= T('State'), length = 64 ),
Field('o_country',type='string',label= T('Country'), length = 64 ),
Field('o_TaxNumber',type='string',label= T('Tax number'), length = 64 ),
Field('o_rootid',type='integer' ),
Field('o_parentid',type='integer' ),
Field('o_levelid',type='integer'), 
Field('o_positionx',type='string', length = 64 ),
Field('o_positiony',type='string', length = 64 ),
Field('o_note',label= 'Note',type = 'text'),
migrate=settings.migrate
)



then extra field, autocomplete is not really necessary

auth.settings.extra_fields['auth_user'] = [ Field('organization', 
'reference organizations', 
  
widget=SQLFORM.widgets.autocomplete(request, db.organizations.o_name, 
id_field=db.organizations.id),
   label = 
T('Organization'))]   


my function to add organization and rows in config table

def add_organization(form):

Always adds new organization
   


#if not form.vars.organization:
   # print form.vars ,form.vars
ret = 
db.organizations.validate_and_insert(o_name=form.vars._autocomplete_organization_o_name_aux)

 
if ret.errors:
form.errors.organizations = ret.errors['name']
else:
   
org = ret.id

Dodamo podatke v config tabelo ko se kreira nova organizacija
holiday_duration1480portalDefault trajanje praznika
vacation_duration1480portalDefault trajanje dopusta
holiday_color1008000portaltemno zelena
vacation_color100ff00portalsvetlo zelena

db.config.insert(co_code = holiday_duration, co_value = '420', 
co_organisation = org, co_note = 'Default trajanje praznika')
db.config.insert(co_code = vacation_duration, co_value = '480', 
co_organisation = org , co_note = 'Default trajanje dopusta')   
 
db.config.insert(co_code = holiday_color, co_value = '008000 ', 
co_organisation = org, co_note = 'Default barva holiday temno zelena') 
db.config.insert(co_code = vacation_color, co_value = '00ff00 ', 
co_organisation = org, co_note = 'Default barva vacation svetlo zelena')
db.config.insert(co_code = minimum_time_period, co_value = '15 ', 
co_organisation = org, co_note = 'Default vrednost časovne periode')


#if not form.vars.organizations:
#print form.vars._autocomplete_organizations_o_name_aux
org_name = form.vars._autocomplete_organizations_o_name_aux
ret = db.organizations.insert(o_name = org_name)


and at the end 

auth.settings.register_onvalidation = add_organization

## create all tables needed by auth if not custom tables
auth.define_tables(username=False, signature=False)


-- 
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: can you execute a command within grid lambda without leaving the function?

2015-02-12 Thread Alex Glaros
when link is clicked, I'd like the auth_user.id from that row to go into a 
dictionary that holds a single id or growing list of email recipients' ids 
for this message.

After that, user will compose an internal message and send it to the list 
of email recipients captured above


-- 
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: can you execute a command within grid lambda without leaving the function?

2015-02-12 Thread Anthony
One option might be to have the link trigger an ajax request that sends the 
ID. That action that receives that request could append the ID to a list 
stored in the session (which you can clear after the email has been sent).

Anthony

On Thursday, February 12, 2015 at 10:37:18 PM UTC-5, Alex Glaros wrote:

 when link is clicked, I'd like the auth_user.id from that row to go into 
 a dictionary that holds a single id or growing list of email recipients' 
 ids for this message.

 After that, user will compose an internal message and send it to the list 
 of email recipients captured above




-- 
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: Expose class into a component

2015-02-12 Thread CrC Nommack
Anthony thank you very much for your answer.
As Leonel's answer partially worked I will try it first before going with 
yours.
Anyway thank you very much.

Kind regards

El jueves, 12 de febrero de 2015, 17:41:00 (UTC+1), Anthony escribió:

 For now you'll probably have to write some custom JS to catch link clicks 
 and load the URL into the component div via Ajax. We could probably add an 
 Ajax trap option to Expose to handle this automatically. Feel free to 
 submit a github issue with this feature request.

 Anthony

 On Thursday, February 12, 2015 at 10:52:54 AM UTC-5, CrC Nommack wrote:

 Hi guys, I have a problem that I don't really know how to deal with.
 I will explain the context:
 I have an *index.html* that calls two components (LOAD)
 One of the components is a controller with an index function and within 
 this function I put the following code:

 def index():
 path = os.path.join(request.folder, 'static', 'folder_files')
 related_media = Expose(path, basename='folder_files')

 return dict(related_media=related_media)


 The view is trivial:


 {{=related_media}}


 The problem is that when I click for example in a folder the result is not 
 loaded in the component.


 Is it possible to make it work only inside the component?


 Thank you very much for your help.

 Kind regards



-- 
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: Expose class into a component

2015-02-12 Thread CrC Nommack
Thank you very much Leonel.
It worked!!

The only thing is that if I click on a picture it doesn't open as a picture 
but as raw data.
Any idea?

Thank you very much.
Kind regards.

El jueves, 12 de febrero de 2015, 17:38:31 (UTC+1), Leonel Câmara escribió:

 You could make the links in the loaded component have a cid with the same 
 id so they will load in the same place. I have never used Expose so this 
 may not be entirely correct

 {{
 related_html = DIV(
 H2(related_media.breadcrumbs(related_media.basename)),
 related_media.paragraph or '',
 related_media.table_folders(),
 related_media.table_files()
 )


 for a in related_html.elements('a'):
 a['cid'] = request.cid
 pass
 }}
 {{=related_html}}





 I'm going around expose xml method because we need to change the DOM.


-- 
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: Absolute beginner unable to get started

2015-02-12 Thread Jim S
How did you install it?

-Jim


On Saturday, February 7, 2015 at 8:59:31 AM UTC-6, MihaW wrote:


 I have installed version w2p 2.9.12 with Python 2.7.6 - on 127.0.0.1 with 
 FF browser. O/s is W7. Example works! But attempts to edit any file at all 
 result in this error. type 'exceptions.IOError'(could not get source 
 code. Very basic mistake on my part? Advice much appreciated!



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


[web2py] Re: auth_user table referenced table

2015-02-12 Thread Yebach
I removed wizard from extra filed.

At least there is only one record inserted into organization table (before 
that it inserted two), but wizzard still returns 0

On Thursday, February 12, 2015 at 11:28:20 AM UTC+1, mcamel wrote:

 Hi,

 It seems wizard is returning id=0 instead of the actual organization id. 
 Try removing the wizard from extra fields to guess more.

 Just in case, you can try this other syntax:

  auth.settings.register_onvalidation.append(lambda form: add_organization(
 form))


 Regards.


 El jueves, 12 de febrero de 2015, 10:18:46 (UTC+1), Yebach escribió:

 Hello

 I have a question regarding adding extra fields to auth_user table 

 now I saw a couple of posts but none answers my question

 I have a table organization. On user registration user adds organization 
 name in form. this value should be inserted into table organization and id 
 of the record into auth_user.organization field. 

 Also some other default values should be inserted into another config 
 table.
 I had this working now I am getting an error 
 class 'psycopg2.IntegrityError' insert or update on table auth_user 
 violates foreign key constraint auth_user_organization_fkey DETAIL: Key 
 (organization)=(0) is not present in table organizations.

 my db.py code

 db.define_table('organizations',
 Field('id',type='id'),
 Field('o_daten', type='datetime',default=request.now),
 Field('o_dateu', type='datetime',default=request.now),
 Field('o_status',type='integer' ),
 Field('o_code',type='string', length = 64 ),
 Field('o_name',type='string', label= T('Organization name'), length = 
 256),
 Field('o_telnumber',type='string',label= T('Telephone number'), 
 length = 64 ),
 Field('o_faxnumber',type='string',label= T('Fax Nb.'), length = 64 ),
 Field('o_street',type='string',label= T('Street'), length = 64 ),
 Field('o_post',type='string',label= T('Post'), length = 64 ),
 Field('o_city',type='string',label= T('City'), length = 64 ),
 Field('o_state',type='string',label= T('State'), length = 64 ),
 Field('o_country',type='string',label= T('Country'), length = 64 ),
 Field('o_TaxNumber',type='string',label= T('Tax number'), length = 64 
 ),
 Field('o_rootid',type='integer' ),
 Field('o_parentid',type='integer' ),
 Field('o_levelid',type='integer'), 
 Field('o_positionx',type='string', length = 64 ),
 Field('o_positiony',type='string', length = 64 ),
 Field('o_note',label= 'Note',type = 'text'),
 migrate=settings.migrate
 )



 then extra field, autocomplete is not really necessary

 auth.settings.extra_fields['auth_user'] = [ Field('organization', 
 'reference organizations', 
   
 widget=SQLFORM.widgets.autocomplete(request, db.organizations.o_name, 
 id_field=db.organizations.id),
label = 
 T('Organization'))]   


 my function to add organization and rows in config table

 def add_organization(form):
 
 Always adds new organization

 

 #if not form.vars.organization:
# print form.vars ,form.vars
 ret = 
 db.organizations.validate_and_insert(o_name=form.vars._autocomplete_organization_o_name_aux)
 
  
 if ret.errors:
 form.errors.organizations = ret.errors['name']
 else:

 org = ret.id
 
 Dodamo podatke v config tabelo ko se kreira nova organizacija
 holiday_duration1480portalDefault trajanje 
 praznika
 vacation_duration1480portalDefault trajanje 
 dopusta
 holiday_color1008000portaltemno zelena
 vacation_color100ff00portalsvetlo zelena
 
 db.config.insert(co_code = holiday_duration, co_value = '420', 
 co_organisation = org, co_note = 'Default trajanje praznika')
 db.config.insert(co_code = vacation_duration, co_value = '480', 
 co_organisation = org , co_note = 'Default trajanje dopusta')   
  
 db.config.insert(co_code = holiday_color, co_value = '008000 ', 
 co_organisation = org, co_note = 'Default barva holiday temno zelena') 
 db.config.insert(co_code = vacation_color, co_value = '00ff00 
 ', co_organisation = org, co_note = 'Default barva vacation svetlo zelena')
 db.config.insert(co_code = minimum_time_period, co_value = '15 
 ', co_organisation = org, co_note = 'Default vrednost časovne periode')
 
 
 #if not form.vars.organizations:
 #print form.vars._autocomplete_organizations_o_name_aux
 org_name = form.vars._autocomplete_organizations_o_name_aux
 ret = db.organizations.insert(o_name = org_name)


 and at the end 

 auth.settings.register_onvalidation = add_organization

 ## create all tables needed by auth if not custom tables
 auth.define_tables(username=False, signature=False)




-- 
Resources:
- http://web2py.com
- 

[web2py] Re: Force authentication to whole app

2015-02-12 Thread Anthony
To take advantage of the decorators at a file level, you can also do this 
at the top level of a file:

auth.requires_login()(lambda: None)()

The decorators ultimately call auth.requires, which itself returns a 
decorator. The above passes a dummy function to that decorator and then 
simply calls it.

Anthony

On Thursday, February 12, 2015 at 6:11:40 AM UTC-5, mcamel wrote:

 Hello,

 You can use @auth* decorators to force authentication to single functions, 
 but how you can force authentication to your whole application?.

 I use this, just after defining auth:

 if not auth.is_logged_in():
 # avoid infinite recursion
 if request.url != auth.settings.login_url:
 # after authentication go to the intended url
 redirect(auth.settings.login_url + '?_next=' + request.env.
 request_uri)

 Any better aproach?.

 You can also exclude certain controllers and/or functions:

 if not auth.is_logged_in():
 if request.controller != 'util' and request.function != 
 'change_language':
 # avoid infinite recursion
 if request.url != auth.settings.login_url:
 # after authentication go to the intended url
 redirect(auth.settings.login_url + '?_next=' + request.env.
 request_uri)

 Regards.




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


Re: [web2py] Drill-down menu with PostgreSQL

2015-02-12 Thread Louis Amon
 a webpage holding 200 locations and requiring 800 queries is not a webpage a 
 user would need. 


That’s actually a very good point !

This page is actually designed for SEO, but even SEO doesn’t go well with 
hundreds of links.

I think I should build a navigation architecture that maps the drill down I 
want to build.
This way I solve both problems : the DAL query will be much simpler  the 
result in terms of SEO will also improve !

Thanks Niphlod for helping me clear that up. Not all answers need to be 
technical :)

 Le 12 févr. 2015 à 12:32, Niphlod niph...@gmail.com a écrit :
 
 if your model is a single table with 4 fields, what's the expected resultset 
 ? a nested dict ? if yes, no queries needed, just python.
 
 BTW: a webpage holding 200 locations and requiring 800 queries is not a 
 webpage a user would need. 
 In other words, what's the maximum number of leaves you want to prefetch ?
 
 
 
 -- 
 Resources:
 - http://web2py.com http://web2py.com/
 - http://web2py.com/book http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py http://github.com/web2py/web2py (Source 
 code)
 - https://code.google.com/p/web2py/issues/list 
 https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to a topic in the Google 
 Groups web2py-users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/web2py/yF1UHKQqseI/unsubscribe 
 https://groups.google.com/d/topic/web2py/yF1UHKQqseI/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 web2py+unsubscr...@googlegroups.com 
 mailto:web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout 
 https://groups.google.com/d/optout.

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


Re: [web2py] Drill-down menu with PostgreSQL

2015-02-12 Thread Niphlod
mind that there's even another angle: given that usually a city resides 
in the same place (same goes for regions, countries, etc etc etc) you can 
carefully cache the computationally expensive resultset and update it 
once a week (or once modifications are made). 
That's what we - dba - call as materialization process: something huge to 
compute, read often, modified rarely...can be computed rarely and stored 
somewhere with the most correct structure that is read-safe.

On Thursday, February 12, 2015 at 1:27:29 PM UTC+1, Louis Amon wrote:

 a webpage holding 200 locations and requiring 800 queries is not a webpage 
 a user would need. 


 That’s actually a very good point !

 This page is actually designed for SEO, but even SEO doesn’t go well with 
 hundreds of links.

 I think I should build a navigation architecture that maps the drill down 
 I want to build.
 This way I solve both problems : the DAL query will be much simpler  the 
 result in terms of SEO will also improve !

 Thanks Niphlod for helping me clear that up. Not all answers need to be 
 technical :)




-- 
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] Expose class into a component

2015-02-12 Thread CrC Nommack
Hi guys, I have a problem that I don't really know how to deal with.
I will explain the context:
I have an *index.html* that calls two components (LOAD)
One of the components is a controller with an index function and within 
this function I put the following code:

def index():
path = os.path.join(request.folder, 'static', 'folder_files')
related_media = Expose(path, basename='folder_files')

return dict(related_media=related_media)


The view is trivial:


{{=related_media}}


The problem is that when I click for example in a folder the result is not 
loaded in the component.


Is it possible to make it work only inside the component?


Thank you very much for your help.

Kind regards

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


Re: [web2py] can we have web2py groups with AD authentication ?

2015-02-12 Thread Richard Vézina
It should did you try ?

There is no better then try...

:)

I am not an expert in AD, but there is sometimes new fields or duplicated
fields that store the same information... So, if it not working don't
conclude hasty that it not working...

Richard

Richard

On Tue, Feb 10, 2015 at 6:12 PM, Gary Cowell gary.cow...@gmail.com wrote:

 I would like my app to authenticate with AD (ldap) for users and passwords.

 But, I'm not in control of the LDAP, and I can't get them to add new
 groups etc. and the app requires users to be in a web2py admin group to do
 certain admin functions within the app.

 So at the moment, I'm using standard auth, where users can self register,
 then I add them to the admin group myself if necessary

 I found a web2py slices for authenticating against AD, but how can I also
 use web2py groups, /instead of/ AD/ldap groups? So authenticate the user
 and password against AD, but use my app groups for additional permissions

 Is it the case of the auth.settings.create_user_groups and
 auth.settings.login_methods [ manage_groups ] options?

 I won't be able to test it sadly until I have access to an ldap server.
 Might be time to run my own for now, I suppose!

 Question for now is, is this possible at all? If so, I will set up and
 configure an ldap server to test it with.

 Thanks


 from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
 auth = Auth(db, hmac_key = Auth.get_or_create_key())

 then

 auth.define_tables(username=True)
 #auth.settings.create_user_groups=False

 after

 # all we need is login

 auth.settings.actions_disabled=['register','change_password','request_reset_password','retrieve_username','profile']

 # you don't have to remember me
 auth.settings.remember_me_form = False

 and

 from gluon.contrib.login_methods.ldap_auth import ldap_auth
 auth.settings.login_methods = [ldap_auth(mode='ad',
 manage_groups= True,
 db = db,
 group_name_attrib = 'cn',
 group_member_attrib = 'member',
 group_filterstr = 'objectClass=Group',
 server='server',
 base_dn='OU=my org unit,DC=domain,DC=domain')]

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


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


[web2py] Re: Expose class into a component

2015-02-12 Thread Leonel Câmara
You could make the links in the loaded component have a cid with the same 
id so they will load in the same place. I have never used Expose so this 
may not be entirely correct

{{
related_html = DIV(
H2(related_media.breadcrumbs(related_media.basename)),
related_media.paragraph or '',
related_media.table_folders(),
related_media.table_files()
)


for a in related_html.elements('a'):
a['cid'] = request.cid
pass
}}
{{=related_html}}





I'm going around expose xml method because we need to change the DOM.

-- 
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: Expose class into a component

2015-02-12 Thread Anthony
For now you'll probably have to write some custom JS to catch link clicks 
and load the URL into the component div via Ajax. We could probably add an 
Ajax trap option to Expose to handle this automatically. Feel free to 
submit a github issue with this feature request.

Anthony

On Thursday, February 12, 2015 at 10:52:54 AM UTC-5, CrC Nommack wrote:

 Hi guys, I have a problem that I don't really know how to deal with.
 I will explain the context:
 I have an *index.html* that calls two components (LOAD)
 One of the components is a controller with an index function and within 
 this function I put the following code:

 def index():
 path = os.path.join(request.folder, 'static', 'folder_files')
 related_media = Expose(path, basename='folder_files')

 return dict(related_media=related_media)


 The view is trivial:


 {{=related_media}}


 The problem is that when I click for example in a folder the result is not 
 loaded in the component.


 Is it possible to make it work only inside the component?


 Thank you very much for your help.

 Kind regards



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