[web2py] Re: track_changes bug or feature?

2013-04-02 Thread demetrio
A little bump on the topic.

Somebody knows something about this?

greetings, Daniel.

El lunes, 25 de marzo de 2013 15:55:19 UTC+1, demetrio escribió:
>
> Hi everyone, 
>
> I have notice an strange behaviour of the track_changes feature (working 
> on web2py 2.3.2 and python 2.7.3). 
>
> Imagine the following structure: 
>
> modules/ 
> ├── classone.py 
> ├── __init__.py 
> └── mymodule 
> ├── classtwo.py 
> └── __init__.py 
>
> (assuming that there is a models/0.py file with the track_changes(True) 
> statement) 
>
> In the file classone.py I have the following: 
> #== 
> #!/usr/bin/env python 
> # coding: utf8 
> from gluon import * 
> *from mymodule.classtwo import ClassTwo* 
>
> class ClassOne(object): 
> def say_something(self): 
> classtwo = ClassTwo() 
> return classtwo.say_something() 
> #== 
>
> And in classtwo.py this: 
> #== 
> #!/usr/bin/env python 
> # coding: utf8 
> from gluon import * 
>
> class ClassTwo(object): 
> def say_something(self): 
> return "Hi!" 
> #== 
>
> In this case, the changes inside ClassTwo are not tracked, but if I 
> change class one to: 
>
> #== 
> #!/usr/bin/env python 
> # coding: utf8 
> from gluon import * 
>
> class ClassOne(object): 
> def say_something(self): 
> *from mymodule.classtwo import ClassTwo* 
> classtwo = ClassTwo() 
> return classtwo.say_something() 
> #== 
>
> Now it works correctly and all the changes are tracked, notice that now 
> the import statement is inside of a method. 
>
> In the first case, the custom_importer() function is only called at the 
> first execution to import ClassTwo, but in the second case, 
> custom_importer its called in all executions. 
>
> I have made an example application with this issue attached to this mail. 
>
> Is this intended or it is a bug? 
>
> greetings, Daniel. 
>
>

-- 

--- 
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: Automatic login if username contains @ : Is this normal ?

2012-11-23 Thread demetrio
I made some progress on this issue.

If ldap_mode is set to None, it always access and creates the user.

Then I set ldap_mode to 'uid' and the @ issue doesn't happen more. But 
there is a little bug in exception handling in the ldap login method, 
because if the user exists but the password is incorrect, it enters anyway. 
You need to set another exception:

*except ldap.INVALID_CREDENTIALS, e:*
*return False*
except ldap.LDAPError, e:
return False
except IndexError, ex: # for AD membership test
return False

I have tested it with 

uid=ad...@host.ext,ou=People,dc=example,dc=com

and with

uid=admin,ou=People,dc=example,dc=com

setting the auth.define_tables(username=True)

and it works ok for me. I didn't try with the 'cn' mode


El viernes, 23 de noviembre de 2012 00:30:28 UTC+1, Massimo Di Pierro 
escribió:
>
> I believe this is a bug in Python-ldap not a bug in web2py. This is a 
> serious bug.
> 1) We have two options: block all usernames containing a @ (but what if 
> the username is legitimate?)
> 2) Fix it in ldap.
>
> In case 2) it would help if somebody could reproduce the problem in a 
> simple python ldap script so we can submit a bug report without web2py.
>
> Massimo
>
>
>
>
> On Thursday, 22 November 2012 11:26:58 UTC-6, demetrio wrote:
>>
>> I have the same issue using web2py 1.99.7. I'm trying to connecto to an 
>> OpenDS LDAP, and if I use any non-existing user with "@" enters 
>> automatically.
>>
>> Is this resolved in a newer release? If I can send some debug info just 
>> tell me.
>>
>> El jueves, 8 de noviembre de 2012 16:26:57 UTC+1, Massimo Di Pierro 
>> escribió:
>>>
>>> I emailed you privately abou this. Asking for for somd debug info. Did 
>>> you get my email?
>>
>>

-- 





[web2py] Re: Automatic login if username contains @ : Is this normal ?

2012-11-22 Thread demetrio
I have the same issue using web2py 1.99.7. I'm trying to connecto to an 
OpenDS LDAP, and if I use any non-existing user with "@" enters 
automatically.

Is this resolved in a newer release? If I can send some debug info just 
tell me.

El jueves, 8 de noviembre de 2012 16:26:57 UTC+1, Massimo Di Pierro 
escribió:
>
> I emailed you privately abou this. Asking for for somd debug info. Did you 
> get my email?

-- 





[web2py] Standalone DAL leaves mysql connections opened

2012-06-22 Thread demetrio

Hi everyone,

I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
standalone DAL. When you do a dav petition with the navigator it makes a 
lot of petitions. Well, the thing is that always there is a connection 
opened (i can see them with PhpMyAdmin)

if self.db: 
self.db._adapter.close()

seeing this issue: 
http://code.google.com/p/web2py/issues/detail?id=731

I have tried a lot of the lines that i found there

something like:

if self.db:
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')

something like:
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()

and even something desesperated like:
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
self.db._adapter.close_all_instances(None)
self.db._adapter.close_all_instances('commit')
self.db._adapter.close_all_instances('rollback')

from gluon.dal import ConnectionPool
ConnectionPool.close_all_instances(None)
ConnectionPool.close_all_instances('commit')
ConnectionPool.close_all_instances('rollback')

from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')

But always, in the best, it leaves at least one connection opened, and i 
don't know how to deal with it.

I have using web2py 1.99.7 in both development and production environments.

Any ideas? in this moment we are building a python mysql script, but we 
want to use DAL to make it runnable on any of the web2py/DAL supported db

Thanks in advance

-- 





[web2py] Using web2py+mod_wsgi for SVN/DAV Auth and Authz

2012-06-01 Thread demetrio
Hi everyone, i've seen this entry on the book: 
http://web2py.com/books/default/chapter/29/9?search=wsgi#Using-web2py-to-authorize-non-web2py-apps
 but 
i think that it needs to have an active session on the web application, and 
I need something a little more complex

I need to ask from a wsgi script if a user is in the system 
(authenthorization) and if that user has access (authorization) to the SVN 
or DAV resource.

I have followed some recipes and i have this

In apache:
# Work around authz and SVNListParentPath issue
RedirectMatch ^(/svntest)$ $1/


# Enable Subversion logging
#CustomLog logs/svn_logfile "%t %u %{SVN-ACTION}e" env=SVN-ACTION



   # Enable Subversion
   DAV svn


   # Directory containing all repository for this path
   SVNParentPath /home/demetrio/www/svn_test


   # Enable repository listing when browing the Location root
   SVNListParentPath On


AuthType Basic
AuthName "User required"
AuthBasicProvider wsgi
WSGIAuthUserScript /home/demetrio/www/wsgi_svn_script/wsgi.py
    WSGIAccessScript /home/demetrio/www/wsgi_svn_script/wsgi.py
Require valid-user




And in the wsgi script (following the instructions of 
http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms):

#Authentication
def check_password(environ, user, password):
if user == 'user':
if password == 'pass':
return True
return False
return None


#Authorization
def allow_access(environ, host):
#test condition
if environ['REQUEST_URI'] == '/svntest/project1':
return True
else:
return False


Now the question, somebody knows how to connect the wsgi script with my 
application?

Thanks in advance


[web2py] help with complex model creation

2011-11-08 Thread demetrio
Hi everyone,

i'm starting a new project with web2py, and now i'm defining the model
of the app and i have some questions.

the "classical" and simplified model (there are lots of tables but the
questions are about those)  is something like:

Table 'companies'
  - id_company
  - name
  - 

Table 'guild'
  - id_guild
  - name
  - 

Table 'construction' (i don't really know if "construction" is the
correct english word for this example, or maybe "building_lot")
  - id_construction
  - name
  - 

And now I have to make the relations. In this case one companies can
have many guilds (i.e: the company 'company1' owns to the 'painters'
guild and the 'doors' guild). This relation would be easy in web2py
with a list:reference.

But the case is that in a building lot, can have one company working
with an specific guild, and in other building lot, the same company
working with another guild.

For example:
   In the construction "A" of 5 apartments, the company "company1"
only works installing windows.
   In the construction "B" of 20 apartments, the company "company1"
only works painting the walls.

In a classic table_has_table model, I could have this:

Table "company_has_guild":
  - id_company_has_guild
  - id_company
  - id_guild

And:

Table "construction_has_company_has_guild" (and at this moment don't
know if this is the best way to make this relation...)
  - id_construction
  - id_company_has_guild

As I have mentioned before, the first relation (company_has_guilds)
with web2py would be easy:

db.define_table("guilds",
   Field("name", "string")
   )

db.define_table("company",
   Field("name", "string"),
   Field("guilds", "list:reference guilds")
   )

Any suggestions about the creation of the second relation
(construction_has_company_has_guild)? Or I have to create the
"classic" table_has_table model? In this case, there is some efficient
way to make it in web2py?

Thanks in advance!
Daniel


[web2py] Problem uploading files.

2011-09-19 Thread demetrio
Hi, i'm having the next traceback when I try to upload a file in the
production server:

Traceback (most recent call last):
  File "/srv/web2py/gluon/main.py", line 442, in wsgibase
parse_get_post_vars(request, environ)
  File "/srv/web2py/gluon/main.py", line 276, in parse_get_post_vars
request.body = copystream_progress(request) ### stores request
body
  File "/srv/web2py/gluon/main.py", line 144, in copystream_progress
copystream(source, dest, size, chunk_size)
  File "/srv/web2py/gluon/fileutils.py", line 366, in copystream
data = src.read(chunk_size)
  File "/usr/lib/python2.6/socket.py", line 377, in read
data = self._sock.recv(left)
timeout: timed out

The problem comes when I try to upload a 1.2mb zip file. If I upload a
text file with less mb, there is no problem. And there is no problem
with the web2py own server. Only in the production machine.

The machine is running web2py 1.98.1 under Debian GNU/Linux 6.0.2
(squeeze) with python 2.6


Does anybody knows whats happening?

Thanks in advance


[web2py] time to contribute with a big app: openMyWork

2011-08-01 Thread demetrio
Hi everyone!

I'm very proud to announce the project openMyWork based on the Web2py
framework.

openMyWork has been created for the Basque Government in Spain, and
it's gonna be the Basque Government's center of future liberations of
open source applications.

The source code available is a beta and there is a little
documentation missing (like an installation manual), we are developing
new features and the next release its gonna be something really big :)
(including documentation in English and Spanish). I hope to have a
website ready on the next month

And now, what is openMyWork?

openMyWork is a collaborative work environment, joining a set of
applications. Here goes a little resume of the apps.

   - openMyForge: a code forge, which can be installed in 2 versions
"lite" and "enterprise". " The "enterprise" version uses svn and a
webdav server, and it's pre-installation is a bit more complicated.
The version "lite" use a filemanager does not use the services of
webdav and svn.
   - openMyDesktop: its a personal web-desktop like the iGoogle
interface, but it can connect to a infinite number of openMyForge
installations to see and merge the data (tasks, bugs, incidences)
of all the projects that you are working in. And it can be extended to
merge data from other sites, like GoogleCode.
   - openMyCalendar: openMyCalendar is a calendar app, based on the
jquery library fullCalendar, and is integrated with and openMyDesktop
openMyForge.
   - CAS: its your cas application, but we added a mobile view for
login and logout.
   - Filemanager: only visible in the "lite" installation, and its the
web2py app called "filemanager" with no modifications.
   - Portal: its a web-frontend, its the web frontend that were used
in the december web2py app contest :)
   - openMyWork: actually its the web2py's admin app but modified to
only install and configure the other apps.

I'm going to talk a little more of the 2 larger applications of the
openMyWork project: openMyForge and openMyDesktop.

openMyForge, as i said before, is a code forge where you can make
private and public projects. It offers the next services:
  - Bugs
  - Incidences
  - Tasks
  - Roadmap
  - Calendars(the openMyCalendar app)
  - Webdav viewer (only in enterprise installation)
  - SVN viewer (only in the enterprise installation)
  - Filemanager (only in the lite installation)
  - ETR ("Editor en Tiempo Real" or "Real Time Editor" in english).
(This is an experimental feature, it is a real time editor like gobby,
and now its based in the google library: mobwrite but in the future we
want to make this with another library like nodeJS or something like
that).

It offers to extract info with the RESTful API (at first, we developed
one, but we moved to the one developed by Massimo)

openMyDesktop its a "merge center" of all the data from openMyForge.
You can visualice and merge the data from many projects in many
openMyForge instances (even a local instance of openMyForge). It
offers this services:
  - Tasks (that can merge with the ones in openMyForge)
  - Notes.

It has a mobile interface (at the moment "read only" features) with
jQueryMobile :)

In the future we want to make a more updates with a social aspect,
like integration with Facebook, chats, etc...

The apps are running here, so you can visit the public frontend of the
application:

http://forjas.infloss.com/ -the frontend-
http://forjas.infloss.com/forja -the openMyForge app with more
projects liberated by the Basque Gobernment-
http://forjas.infloss.com/escritorio -the openMyDesktop app but you
will need an user :( -

Manuals:
http://forjas.infloss.com/dav/openmywork/openmydesktop (user manual
but in spanish only)
http://forjas.infloss.com/dav/openmywork/openmyforge (lite-
installation: user manual but in english only)

In order to see the "private part" you will need an user but for the
moment the registration is closed (in the next relase we will open the
registration to everyone :D) but you can see how to administer the
forge application with the manual.

In the next release we are gonna to include this (and more ;D):
  - In the online version there are a lot of usability flaws and its
code is very old now, but we are working in a new interface (like
GQueues) for the layout of bugs, incidences, task and roadmap services
that it will make more usable. In fact, the GQueues interface is
available in the trunk version, and you can see some screenshots in
the forge-lite manual.
  - Registration open to everybody
  - Wiki
  - bug corrections.
  - Read and write from openMyDesktop to openMyForge.

We know that we are not offering you the 100% of the application now,
but we wanted to make it public, since the project was released in
January. And so we self-oblige us to have the all documentation in
English for you (and a better installations system) as soon as
possible ;)

For now I invite you to visit the public frontend of the application
and wait till the next release to do any type of instal

[web2py] Re: apologies

2011-07-20 Thread demetrio
Hi Massimo, i sent a mail a few days ago asking about some way to
provide "simultaneous multi-language" support to our application. If
you (or somebody) could give some suggestion would be nice.

http://groups.google.com/group/web2py/browse_thread/thread/d6525c6623aad50c

thanks in advance

On 20 jul, 19:39, Massimo Di Pierro 
wrote:
> Hello everybody,
>
> I apologize I have been not active on the list for a few days does to
> a series of circumstances: travel, power outage, jetlag. Anyway, looks
> like Anthony, Jonathan and a few others manage to answer almost all
> the questions which proves I am not needed and that is good. ;-)
> Anyway, if there is any pending issue feel free to ping.
>
> Massimo


[web2py] Simultaneous multi-language system.

2011-07-13 Thread demetrio
Hi everyone, i don't know if "Simultaneous multi-language system" is
the correct way to say what i need... i'll explain myself.

I'm developing an application that by request of our customer, needs
to have 2 languages at the same time. For example, if this app were in
spanish and english, in the navigator should appear something like:

Casa / House

In the view we want to do something like this

{{=T("House", "es-es")}} / {{=T("House", "en-en")}}

But i don't know if web2py can permit to do this or something like
that.

I was thinking of writing a function like this:

def MultiT(text,separator=" / "):
T.force("es-es")
ret_text = T(text)
T.force("en-en")
ret_text += separator + T(text)
return ret_text

But it does not work. Also, do not know how this affects the system
when updating the language files with the strings to translate (now
the files are updated automatically when pressing the "update
languages" button in admin, and I guess that it would make it on run
time.

Any sugestions?

Best regards
Daniel


[web2py] Missing authorization header in 1.97.1 under Apache

2011-07-05 Thread demetrio
Hi, we have a very strange behaviour.

We have 2 apps:

CAS (the one from the free appliances), modified in order to receive 2
types more of authorization.
DevelApp this application sends a REST call to CAS to create a user.

This works under web2py 1.94.6 in both rocket and apache servers,
included 1.97.1 with rocket.

But using 1.97.1 on production, with apache, we don't receive the
"authorization" header.

Whe make the rest petition in this way:

@staticmethod
def create_user(data):
admin_auth="admin %s" % base64.b64encode(CAS_PASSPHRASE)
rret=rest("%s/user" % (CAS_REST),
  method='put',
  headers={'ACCEPT': 'application/json',
   'CONTENT-TYPE': 'application/json',
   'AUTHORIZATION': admin_auth},
   data=json.dumps([{"name": data.name,
"email": data.email, "password": data.password}])
   )

the header is called "authorization" as mandated by the standard. but
in 1.97.1 under apache, we dont receive the
"request.env.http_authorization" variable.

somebody knows why happen this?

thanks in advance


[web2py] recursive tree views

2011-05-30 Thread demetrio
Hi everyone, I have a question about the views and their posibility to
create "tree views" recursively.

I want something like this in a view:

{{for item in items:}}
here goes the main item data.
   
   {{if item.childs:}}
   HERE GOES THE SAME STRUCTURE.
   {{pass}}

{{pass}}

the problem is that the childs can have their own childs, and so on.

Somebody knows if there is some way to do this with the views system?

The final html is more complex with lots of CSS classes, and we want
to separate the views and the code as possible to make it easier to
maintain (and let to one graphic designer modify everything without
have to touch python files).

Thanks in advance,

Best regards,
Daniel


[web2py] New web2py app: Airea.me

2011-05-27 Thread demetrio
Hi everyone,

i'm very proud to announce "Airea.me" (in english it's something like
"aerate me").

This application was made into the challenge "abredatos". A
competition held in Spain, based on the creation of an application
within 48 hours using open data.

Our team, decided to use web2py, jQuery, jQueryMobile and some of the
Google APIs (maps and charts).

We use the data available in the Basque Government in Spain about the
air quality.And the data are treated as measured by the World Health
Organization

All the code is available here: https://github.com/plexxoo/airea.me
And this is the development team: http://live.abredatos.es/teams/41

The application is forced to spanish, because it was imposible to us,
to make it multilingual (especially the big texts) in only 48 hours.
Although some text strings are in English using the translation system
web2py.

We know that there are several bugs, but we can not touch the code yet
to decide a winner of the challenge.

You can access the application here: http://airea.me from your
computer or from a mobile device ;)

Best Regards.
Daniel.


[web2py] Create table without id field

2010-12-13 Thread demetrio
Hi everyone,

i've searched if there is any way to create a table without an id
field. I've tryed with: param "primarykey = None" but this doesn't
works.

There is any way to do it?

Thanks


[web2py] Problem with id.represent since 1.89.4 and newer

2010-11-22 Thread demetrio
Hi,

I have a problem with the represent functionality. In version 1.89.1
it was working fine, but then i updated to 1.89.4 and now to 1.89.5 (I
don't know if it happens on .2 and .3), and it doesn't works.
Moreover, the fields with the "reference", now show the id of the
table instead the format that i have specified.

I don't know if the represent functionality has changed since 1.89.1
or i'm doing something wrong.

One example is this:

### begins code 
@auth.requires_login()
def index():
# Clean user acl
vip_user.clean_project()

# Prepare user's desktop by profile in application
if vip_user.is_admin:
response.menu += admin_menu
db.project_card.id.represent = lambda id: DIV(A(T("Team"),
_href=URL(r=request, c='project_team', f='index', args=(id))),"
",A(T("Services"), _href=URL(r=request, c='project_service',
f='index', args=(id
query = None
else:

db.project_card.id.represent = lambda id: DIV(A(T("Work"),
_href=URL(r=request, c='project', f='index', args=(id)))," ",
A(T("Card"), _href=URL(r=request, c='project_card', f='read',
args=(id
query=((db.project_card.id==db.project_team.project) &
(db.project_team.user==vip_user.id))

form = crud.select(db.project_card,
   query = query,
   fields = ['project_card.id',
'project_card.name',  'project_card.title',  'project_card.type',
'project_card.status',  'project_card.start_date',
'project_card.end_date' ],
   headers = {'project_card.id': T("Actions"),
'project_card.name': 'Nombre',  'project_card.title': 'Título',
'project_card.type': 'Tipo',  'project_card.status': 'Estado',
'project_card.start_date': 'Inicio',  'project_card.end_date':
'Finalización' })

return dict(form=form, user=vip_user)

### ends code 


And the table is defined like this:

### begins code ##

db.define_table('project_card',
Field('name', 'string', length=50, required=True, notnull=True,
label=T('Nombre')),
Field('title', 'string', length=200, required=True,
label=T('Título')),
Field('type', 'reference project_type', required=True,
label=T('Tipo')),
Field('private', 'reference privacity', required=True,
label=T('Privacidad')),
Field('status', 'reference project_status', required=True,
label=T('Estado')),
Field('description', 'text', required=True,
label=T('Descripción')),
Field('start_date', 'datetime', required=True, label=T('Inicio')),
Field('end_date', 'datetime', required=True,
label=T('Finalización')),
Field('objetive', 'text', label=T('Alcance')),
Field('resume', 'text', label=T('Resumen')),
Field('url', 'string', length=400, label=T('Url')),
format='%(name)s')

### ends code 


Regards


[web2py] web2py converts the data to thml chars from controller to view

2010-11-15 Thread demetrio
Hi everyone!

When I try to send html code to a view web2py automatically converts
it to html characters (i.e.: the character "<" is converted to "<")

There is any way to make the unescape the data?

Thanks in advance.

demetrio


[web2py] Re: web2py 1.89.1 is OUT

2010-11-13 Thread demetrio
I had the same problem, that code works fine. Thx dspiteself

On 12 nov, 22:23, dspiteself  wrote:
> there was a problem loading my static files in the designer
>
> I would push it but our project uses git here is a patch.
> /***
> fix web2py bug when static path matches
>
> ex:
> filepath =/test/dojox
> path = /test/dojo
>
> passes '/'.join(file_path).startswith('/'.join(path))
> invalid index exception thrown by path.append(file_path[len(path)])
> len(path):2
> len(filepath):
>
> ***/
>
> diff --git a/src/applications/admin/views/default/design.html b/src/
> applications/admin/views/default/design.html
> index f50093e..afbc996 100644
> --- a/src/applications/admin/views/default/design.html
> +++ b/src/applications/admin/views/default/design.html
> @@ -203,8 +203,8 @@ for c in controllers: controller_functions
> +=[c[:-3]+'/%s.html'%x for x in functi
>        items=file.split('/')
>        file_path=items[:-1]
>        filename=items[-1]
> -      while path!=file_path:
> -          if '/'.join(file_path).startswith('/'.join(path)):
> +      while path!=file_path:
> +          if len(file_path)>= len(path) and all([ v==file_path[k] for
> k,v in enumerate(path)]):
>                path.append(file_path[len(path)])
>                thispath='static__'+'__'.join(path)
>      }}
>
> On Nov 12, 9:22 am, mdipierro  wrote:
>
> > Please give it a try and report any bug.
>
> >1.89.1
> > - new admin layout (thanks Branko Vukelic)
> > - new admin search
> > - new admin language selector (thanks Yair)
> > - new Welcome app (thanks Martin Mulone)
> > - beter wizard
> > - admin support for DEMO_MODE=True
> > - admin exposes GAE deployment button (always)
> > - MENU support None links (thanks Michael Wolfe)
> > - web2py.py -J for running cron (thanks Jonathan Lundell)
> > - fixed ~db.table.id on GAE (thanks MicLee)
> > - service.jsonrpc supports service.JsonRpcException (thanks Matt)
> > - many small bug fixes.
>
>


[web2py] How to make a modal+ajax form "manually"?

2010-11-13 Thread demetrio
Hi everyone,

i'm doing a desktop like iGoogle, with boxes containing information
from different sources (it can be the same application, or other
apps). So I need send my own forms (like "available_boxes", "modify
content preferences" and so)

I saw that the modal plugin is old and now is located inside
plugin_wiki, but I need to do something like that with my own forms.

Is there any way to do it "manually"?

Thanks in advance.


[web2py] Creating debug.html

2010-11-12 Thread demetrio
Hi, I've realized that it might be helpful, to include a template
called "debug.html" with the same code found in "generic.html." but
without the {{extend}} statement. I am using in my development and
saves me some time to write several "BEAUTIFY" calls.

When I want to be in "development mode", I just write {{include
'debug.html'}} in my template.

The code would be:

{{=BEAUTIFY(response._vars)}}
admin
request
request{{=BEAUTIFY(request)}}

session
session{{=BEAUTIFY(session)}}

response
response{{=BEAUTIFY(response)}}
auth.user
auth.user{{=BEAUTIFY(auth.user)}}
jQuery('.hidden').hide();


I also added the variable auth.user to this code.

I hope you find this something useful.


[web2py] Using CAS and @auth.requires_login() decorator

2010-11-08 Thread demetrio
Hi,

i'm trying to use CAS in my project, I can login and logout etc... but
if I use any decorator like @auth.requires_login() it shows the web2py
default login form.

There is any way to use the auth decorators with cas?

I've search in this group messages but i didn't find something useful
for my case.

Thx in advance


[web2py] Re: customizating the headers of the result in crud.search

2010-11-05 Thread demetrio
It seems that it's been a long day...

{{if not rows:}}
No matches found
{{else:}}
{{=SQLTABLE(rows,headers={"field.id":"custom name id",
"field.name":"custom name"})}}
{{pass}}


more simple... impossible...

Sorry for wasting your time :(

On 5 nov, 18:06, demetrio  wrote:
> I think I got excited too soon. I tried these method and it seems that
> it not works.
>
> This is the traceback:
>
> Traceback (most recent call last):
>   File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/
> restricted.py", line 188, in restricted
>     exec ccode in environment
>   File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/
> applications/calendar/views/calendars/search.html", line 97, in
> 
>   File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/
> sqlhtml.py", line 1192, in __init__
>     columns = sqlrows.colnames
> AttributeError: 'list' object has no attribute 'colnames'
>
> One question, i'm using web2py Version 1.87.3. Can it be that this
> funcionality is applied on trunk or newer versions?
>
> Thx again for your time.
>
> On 2 nov, 16:04, demetrio  wrote:
>
> > Thanks a lot Massimo!
>
> > On 2 nov, 14:58, mdipierro  wrote:
>
> > > Yes. In the view, instead of
>
> > > {{=rows}}
>
> > > do
>
> > > {{=SQLTABLE(rows,headers=)}}
>
> > > On Nov 2, 5:43 am, demetrio  wrote:
>
> > > > Hi, first of all sorry if I made any mistake in english :)
>
> > > > When i try to make acrud.search(), i can customize the names of the
> > > > search form, but i cant do the same with the results' headers.
>
> > > > def search():
> > > >     db.licenses.id.represent = lambda id: \
> > > >         DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ",
> > > > A('read',_href=URL(r=request, f='read', args=(id))),"
> > > > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?")
> > > > +"')",_href=URL(r=request, f='delete', args=(id
> > > >     form, rows =crud.search(db.licenses, field_labels =
> > > > {'id':'ID','name':'Name'})
> > > >     return dict(form=form, rows=rows)
>
> > > > With this, code my form is something like:
>
> > > >  ID  
> > > >  Name  
>
> > > > but my results table is:
>
> > > > licenses.id                licenses.name
> > > > --
> > > > edit read delete         resultname1
> > > > edit read delete         resultname2
> > > > edit read delete         resultname3
>
> > > > Do you know if there is any posibility to customize that header
> > > > names?,
>
> > > > it will be nice if I could use the "headers" parameter like in the
> > > >crud.search() method because you can do something like this modifying
> > > > the represent of the id
>
> > > > Search Form:
> > > >  **ID**  
> > > >  Name  
>
> > > > Results:
>
> > > > **Actions**                    Name
> > > > --
> > > > edit read delete         resultname1
> > > > edit read delete         resultname2
> > > > edit read delete         resultname3
>
> > > > notice that the field licenses.id in the form is named **ID**, and in
> > > > the results is named **Actions**
>
> > > > Thats all, thanks in advance :)
>
>


[web2py] Re: How to make a dropbox in a create.form with IS_IN_DB and an join of multiple tables

2010-11-05 Thread demetrio
At the moment we are developing the app in a private SVN server, but I
think that we are gonna release the project on January-February (more
or less), and if nothing changes, it will be open source.

Anyway, i'll speak with the other developer on the next monday about
this.

best regards

On 4 nov, 20:09, Richard Vézina  wrote:
> Hello!
>
> I am very interresting in your dev.
>
> I would like to help if possible.
>
> Richard
>
> On Thu, Nov 4, 2010 at 2:16 PM, demetrio  wrote:
> > Hi everyone!
>
> > I'm doing an app with fullcalendar (http://arshaw.com/fullcalendar/)
> > and now i'm with all the events and calendar cruds.
>
> > Its time to add some logic to the crud.create() of the events, an only
> > let the user to add events in his/her calendars, not in ALL the
> > calendars.
>
> > I have this:
>
> > db.define_table('calendars',
> >    Field('name', 'string', required=True, notnull=True),
> >    #Field('project_id', 'reference', default=None, required=True),
> >    format='%(name)s')
>
> > db.define_table('events',
> >    Field('title', 'string', required=True, notnull=True,
> > label=T('Title')),
> >    Field('place', 'string', label=T('Place')),
> >    Field('description', 'text', label=T('Description')),
> >    Field('init_date', 'datetime', required=True, label=T('Init
> > date')),
> >    Field('end_date', 'datetime', required=True, label=T('End date')),
> >    Field('calendar_id', 'reference calendars', label=T('Calendar')),
> >    Field('all_day', 'boolean', default=False, required=True,
> > label=T('All day')),
> >    format='%(title)s'
> >    )
>
> > db.define_table('user_calendars',
> >    Field('calendar', 'reference calendars', required=True,
> > notnull=True, label=T('Calendar')),
> >    Field('color', 'string', default="blue", required=True,
> > label=T('Color')),
> >    Field('fullcalendar_class', 'string', required=True,
> > writable=False, readable=False),
> >    Field('permissions', 'string', required=True,
> > label=T('Permissions'), requires=IS_IN_SET(['r', 'rw', 'owner'],
> > zero=None)),
> >    Field('user_id', 'reference auth_user', required=True,
> > notnull=True, label=T('User')),
> >    format='')
>
> > With that model defined, in the events crud, will appear ALL the
> > calendars, so i have tried to do something like this:
>
> > def create():
> >    query = ((db.user_calendars.calendar == db.calendars.id)  &
> > (db.user_calendars.user_id == auth.user.id)  &
> > ((db.user_calendars.permissions =="owner") |
> > (db.user_calendars.permissions=="rw")))
> >    db.events.calendar_id.requires =IS_IN_DB(db, query, zero=None )
> >    return dict(form=crud.create(db.events))
>
> > And i found that the IS_IN_DB doesn't admit SQL queries xD
>
> > the query is something like: "give me all my calendars and the ones
> > where i can write"
>
> > Is there any "quick" and optimal solution to make all of this in the
> > controller? or i have to customize the crud form in the view?.
>
> > Thanks in advance!
>
>


[web2py] Re: How to make a dropbox in a create.form with IS_IN_DB and an join of multiple tables

2010-11-05 Thread demetrio
It works!

Thank you very much!

On 4 nov, 22:03, howesc  wrote:
> your problem is where you put the query in the IS_IN_DB.  try
> modifying to put the query in the first spot.  something like:
>
>                          requires=IS_IN_DB(db((db.file_asset.type ==
> db.file_asset_type.id) &
>
> (db.file_asset_type.name=='Album Art')),
>                                            db.file_asset.id, '%
> (name)s')),
>
> (no that is not from your example, but a clipping from one of my
> models)
>
> cfh
>
> On Nov 4, 11:16 am, demetrio  wrote:
>
> > Hi everyone!
>
> > I'm doing an app with fullcalendar (http://arshaw.com/fullcalendar/)
> > and now i'm with all the events and calendar cruds.
>
> > Its time to add some logic to the crud.create() of the events, an only
> > let the user to add events in his/her calendars, not in ALL the
> > calendars.
>
> > I have this:
>
> > db.define_table('calendars',
> >     Field('name', 'string', required=True, notnull=True),
> >     #Field('project_id', 'reference', default=None, required=True),
> >     format='%(name)s')
>
> > db.define_table('events',
> >     Field('title', 'string', required=True, notnull=True,
> > label=T('Title')),
> >     Field('place', 'string', label=T('Place')),
> >     Field('description', 'text', label=T('Description')),
> >     Field('init_date', 'datetime', required=True, label=T('Init
> > date')),
> >     Field('end_date', 'datetime', required=True, label=T('End date')),
> >     Field('calendar_id', 'reference calendars', label=T('Calendar')),
> >     Field('all_day', 'boolean', default=False, required=True,
> > label=T('All day')),
> >     format='%(title)s'
> >     )
>
> > db.define_table('user_calendars',
> >     Field('calendar', 'reference calendars', required=True,
> > notnull=True, label=T('Calendar')),
> >     Field('color', 'string', default="blue", required=True,
> > label=T('Color')),
> >     Field('fullcalendar_class', 'string', required=True,
> > writable=False, readable=False),
> >     Field('permissions', 'string', required=True,
> > label=T('Permissions'), requires=IS_IN_SET(['r', 'rw', 'owner'],
> > zero=None)),
> >     Field('user_id', 'reference auth_user', required=True,
> > notnull=True, label=T('User')),
> >     format='')
>
> > With that model defined, in the events crud, will appear ALL the
> > calendars, so i have tried to do something like this:
>
> > def create():
> >     query = ((db.user_calendars.calendar == db.calendars.id)  &
> > (db.user_calendars.user_id == auth.user.id)  &
> > ((db.user_calendars.permissions =="owner") |
> > (db.user_calendars.permissions=="rw")))
> >     db.events.calendar_id.requires =IS_IN_DB(db, query, zero=None )
> >     return dict(form=crud.create(db.events))
>
> > And i found that the IS_IN_DB doesn't admit SQL queries xD
>
> > the query is something like: "give me all my calendars and the ones
> > where i can write"
>
> > Is there any "quick" and optimal solution to make all of this in the
> > controller? or i have to customize the crud form in the view?.
>
> > Thanks in advance!
>
>


[web2py] Re: customizating the headers of the result in crud.search

2010-11-05 Thread demetrio
I think I got excited too soon. I tried these method and it seems that
it not works.

This is the traceback:

Traceback (most recent call last):
  File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/
restricted.py", line 188, in restricted
exec ccode in environment
  File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/
applications/calendar/views/calendars/search.html", line 97, in

  File "/home/demetrio/devel/web2py_devel/trunk/devel/web2py/gluon/
sqlhtml.py", line 1192, in __init__
columns = sqlrows.colnames
AttributeError: 'list' object has no attribute 'colnames'

One question, i'm using web2py Version 1.87.3. Can it be that this
funcionality is applied on trunk or newer versions?

Thx again for your time.



On 2 nov, 16:04, demetrio  wrote:
> Thanks a lot Massimo!
>
> On 2 nov, 14:58, mdipierro  wrote:
>
> > Yes. In the view, instead of
>
> > {{=rows}}
>
> > do
>
> > {{=SQLTABLE(rows,headers=)}}
>
> > On Nov 2, 5:43 am, demetrio  wrote:
>
> > > Hi, first of all sorry if I made any mistake in english :)
>
> > > When i try to make acrud.search(), i can customize the names of the
> > > search form, but i cant do the same with the results' headers.
>
> > > def search():
> > >     db.licenses.id.represent = lambda id: \
> > >         DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ",
> > > A('read',_href=URL(r=request, f='read', args=(id))),"
> > > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?")
> > > +"')",_href=URL(r=request, f='delete', args=(id
> > >     form, rows =crud.search(db.licenses, field_labels =
> > > {'id':'ID','name':'Name'})
> > >     return dict(form=form, rows=rows)
>
> > > With this, code my form is something like:
>
> > >  ID  
> > >  Name  
>
> > > but my results table is:
>
> > > licenses.id                licenses.name
> > > --
> > > edit read delete         resultname1
> > > edit read delete         resultname2
> > > edit read delete         resultname3
>
> > > Do you know if there is any posibility to customize that header
> > > names?,
>
> > > it will be nice if I could use the "headers" parameter like in the
> > >crud.search() method because you can do something like this modifying
> > > the represent of the id
>
> > > Search Form:
> > >  **ID**  
> > >  Name  
>
> > > Results:
>
> > > **Actions**                    Name
> > > --
> > > edit read delete         resultname1
> > > edit read delete         resultname2
> > > edit read delete         resultname3
>
> > > notice that the field licenses.id in the form is named **ID**, and in
> > > the results is named **Actions**
>
> > > Thats all, thanks in advance :)
>
>


[web2py] How to make a dropbox in a create.form with IS_IN_DB and an join of multiple tables

2010-11-04 Thread demetrio
Hi everyone!

I'm doing an app with fullcalendar (http://arshaw.com/fullcalendar/)
and now i'm with all the events and calendar cruds.

Its time to add some logic to the crud.create() of the events, an only
let the user to add events in his/her calendars, not in ALL the
calendars.

I have this:

db.define_table('calendars',
Field('name', 'string', required=True, notnull=True),
#Field('project_id', 'reference', default=None, required=True),
format='%(name)s')

db.define_table('events',
Field('title', 'string', required=True, notnull=True,
label=T('Title')),
Field('place', 'string', label=T('Place')),
Field('description', 'text', label=T('Description')),
Field('init_date', 'datetime', required=True, label=T('Init
date')),
Field('end_date', 'datetime', required=True, label=T('End date')),
Field('calendar_id', 'reference calendars', label=T('Calendar')),
Field('all_day', 'boolean', default=False, required=True,
label=T('All day')),
format='%(title)s'
)


db.define_table('user_calendars',
Field('calendar', 'reference calendars', required=True,
notnull=True, label=T('Calendar')),
Field('color', 'string', default="blue", required=True,
label=T('Color')),
Field('fullcalendar_class', 'string', required=True,
writable=False, readable=False),
Field('permissions', 'string', required=True,
label=T('Permissions'), requires=IS_IN_SET(['r', 'rw', 'owner'],
zero=None)),
Field('user_id', 'reference auth_user', required=True,
notnull=True, label=T('User')),
format='')



With that model defined, in the events crud, will appear ALL the
calendars, so i have tried to do something like this:

def create():
query = ((db.user_calendars.calendar == db.calendars.id)  &
(db.user_calendars.user_id == auth.user.id)  &
((db.user_calendars.permissions =="owner") |
(db.user_calendars.permissions=="rw")))
db.events.calendar_id.requires =IS_IN_DB(db, query, zero=None )
return dict(form=crud.create(db.events))

And i found that the IS_IN_DB doesn't admit SQL queries xD

the query is something like: "give me all my calendars and the ones
where i can write"

Is there any "quick" and optimal solution to make all of this in the
controller? or i have to customize the crud form in the view?.

Thanks in advance!


[web2py] Re: customizating the headers of the result in crud.search

2010-11-02 Thread demetrio
Thanks a lot Massimo!

On 2 nov, 14:58, mdipierro  wrote:
> Yes. In the view, instead of
>
> {{=rows}}
>
> do
>
> {{=SQLTABLE(rows,headers=)}}
>
> On Nov 2, 5:43 am, demetrio  wrote:
>
> > Hi, first of all sorry if I made any mistake in english :)
>
> > When i try to make a crud.search(), i can customize the names of the
> > search form, but i cant do the same with the results' headers.
>
> > def search():
> >     db.licenses.id.represent = lambda id: \
> >         DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ",
> > A('read',_href=URL(r=request, f='read', args=(id))),"
> > ",A('delete',_onclick="return confirm('" + T("Are you sure to delete?")
> > +"')",_href=URL(r=request, f='delete', args=(id
> >     form, rows = crud.search(db.licenses, field_labels =
> > {'id':'ID','name':'Name'})
> >     return dict(form=form, rows=rows)
>
> > With this, code my form is something like:
>
> >  ID  
> >  Name  
>
> > but my results table is:
>
> > licenses.id                licenses.name
> > --
> > edit read delete         resultname1
> > edit read delete         resultname2
> > edit read delete         resultname3
>
> > Do you know if there is any posibility to customize that header
> > names?,
>
> > it will be nice if I could use the "headers" parameter like in the
> > crud.search() method because you can do something like this modifying
> > the represent of the id
>
> > Search Form:
> >  **ID**  
> >  Name  
>
> > Results:
>
> > **Actions**                    Name
> > --
> > edit read delete         resultname1
> > edit read delete         resultname2
> > edit read delete         resultname3
>
> > notice that the field licenses.id in the form is named **ID**, and in
> > the results is named **Actions**
>
> > Thats all, thanks in advance :)
>
>


[web2py] customizating the headers of the result in crud.search

2010-11-02 Thread demetrio
Hi, first of all sorry if I made any mistake in english :)

When i try to make a crud.search(), i can customize the names of the
search form, but i cant do the same with the results' headers.

def search():
db.licenses.id.represent = lambda id: \
DIV(A('edit',_href=URL(r=request, f='update', args=(id)))," ",
A('read',_href=URL(r=request, f='read', args=(id))),"
",A('delete',_onclick="return confirm('" + T("Are you sure to delete?")
+"')",_href=URL(r=request, f='delete', args=(id
form, rows = crud.search(db.licenses, field_labels =
{'id':'ID','name':'Name'})
return dict(form=form, rows=rows)


With this, code my form is something like:

 ID  
 Name  

but my results table is:

licenses.idlicenses.name
--
edit read delete resultname1
edit read delete resultname2
edit read delete resultname3

Do you know if there is any posibility to customize that header
names?,

it will be nice if I could use the "headers" parameter like in the
crud.search() method because you can do something like this modifying
the represent of the id

Search Form:
 **ID**  
 Name  

Results:

**Actions**Name
--
edit read delete resultname1
edit read delete resultname2
edit read delete resultname3

notice that the field licenses.id in the form is named **ID**, and in
the results is named **Actions**

Thats all, thanks in advance :)