Re: reverse drops the project from the url returned

2009-12-28 Thread Raja
Are you running it through a mod-python handler? From your urls.py, it
looks like it would handle ^support as the first level match and then
continue for "/case", so the reverse URL seems to be correct, i.e. /
support/case/1.

How are you tacking the "/helpdesk" to your request initially?


On Dec 29, 6:22 am, davathar  wrote:
> I'm stuck on a "reverse" problem.  The 'case' view is supposed to
> record posted info, then reload the same page.  But it's dropping the
> first part of the URL on the redirect and I've not been able to figure
> out why.
>
> It should be going to .com/helpdesk/support/case/1/  But it's going
> to .com/support/case/1/
>
> I'm sure it's something simple as I've had the problem in the past and
> fumbled my way through it.  But I can't find it this time.  Hopefully
> the below pasted lines show all the necessary detail.
>
> Anyone see my error?
>
> helpdesk.urls:
> urlpatterns = patterns('',
>     (r'^support/', include('helpdesk.support.urls')),
> )
>
> helpdesk.support.urls:
> urlpatterns = patterns('helpdesk.support.views',
>     (r'^case/(?P\d+)/$', 'case',{},'case_url' ),
> )
>
> helpdesk.support.views:
> def case(request, case):
>     return HttpResponseRedirect(reverse('case_url', args=(case.id,)))
> # Redirect back here after POST
>
> -Shane

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Mysql triggers with django

2009-12-28 Thread Marc Aymerich
On Tue, Dec 29, 2009 at 5:47 AM, Marc Aymerich  wrote:

> well, I found this one.
>
> http://www.eflorenzano.com/blog/post/database-triggers-arent-evil-and-they-actually-kin/
>
> I've tried to implement something like that in mysql with my model but I
> get this error:
>
> _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't
> run this command now")
>
> this is my implementation:
>
> from django.db.models import signals
> from ucp.panel import models
>
> sql = """
>
> DROP TRIGGER IF EXISTS new_domain;
> CREATE TRIGGER new_domain BEFORE INSERT ON panel_domain
> FOR EACH ROW
> BEGIN
>  DECLARE service integer;
> IF ( NEW.hosted ) THEN
> SET @domain = SUBSTRING(LCASE(NEW.name),'.',-1);
>  SET @domain = CONCAT('domain',@domain);
> SELECT service_id INTO service FROM panel_service WHERE
> specific_da...@domain;
>  INSERT INTO panel_order (service, member, description, included,
> discount, discharge_date, cessation_date)
> VALUES(@service,NEW.member_id,NEW.name,0,0,CURTIME(),CURTIME());
>  END IF;
> END;
>
> """
>
> def create_trigger(app, created_models, verbosity, **kwargs):
> from django.db import connection
> cursor = connection.cursor()
> cursor.execute(sql)
> signals.post_syncdb.connect(create_trigger, sender=models)
>
>
> any idea¿¿
>
> thanks!
> Marc.
>
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
> execute_manager(settings)
>   File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py",
> line 362, in execute_manager
> utility.execute()
>   File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py",
> line 303, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
> 195, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
> 222, in execute
> output = self.handle(*args, **options)
>   File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
> 351, in handle
> return self.handle_noargs(**options)
>   File
> "/usr/lib/pymodules/python2.6/django/core/management/commands/syncdb.py",
> line 99, in handle_noargs
> emit_post_sync_signal(created_models, verbosity, interactive)
>   File "/usr/lib/pymodules/python2.6/django/core/management/sql.py", line
> 205, in emit_post_sync_signal
> interactive=interactive)
>   File "/usr/lib/pymodules/python2.6/django/dispatch/dispatcher.py", line
> 166, in send
> response = receiver(signal=self, sender=sender, **named)
>   File "/var/www/ucp/../ucp/panel/management.py", line 24, in
> create_trigger
> cursor.execute(sql)
>   File "/usr/lib/pymodules/python2.6/django/db/backends/util.py", line 19,
> in execute
> return self.cursor.execute(sql, params)
>   File "/usr/lib/pymodules/python2.6/django/db/backends/mysql/base.py",
> line 84, in execute
> return self.cursor.execute(query, args)
>File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in
> execute
> if not self._defer_warnings: self._warning_check()
>   File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 75, in
> _warning_check
> warnings = self._get_db().show_warnings()
>   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 300, in
> show_warnings
> self.query("SHOW WARNINGS")
> _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't
> run this command now")
>
>
>
I get this warning when I execute a syncdb ('python manage.py syncdb').
Python creates all tables, auth system creates superuser .. and then..
appears this warning. ¿is there something wrong? Because now I see that the
trigger is created in the database.




> On Tue, Dec 29, 2009 at 2:49 AM, Marc Aymerich wrote:
>
>> Hello,
>> Is possible to implement mysql triggers with django?? there are some
>> documentation about it?
>>
>> Thanks!!
>> Marc
>>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Mysql triggers with django

2009-12-28 Thread Marc Aymerich
well, I found this one.
http://www.eflorenzano.com/blog/post/database-triggers-arent-evil-and-they-actually-kin/

I've tried to implement something like that in mysql with my model but I get
this error:

_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't
run this command now")

this is my implementation:

from django.db.models import signals
from ucp.panel import models

sql = """

DROP TRIGGER IF EXISTS new_domain;
CREATE TRIGGER new_domain BEFORE INSERT ON panel_domain
FOR EACH ROW
BEGIN
 DECLARE service integer;
IF ( NEW.hosted ) THEN
SET @domain = SUBSTRING(LCASE(NEW.name),'.',-1);
 SET @domain = CONCAT('domain',@domain);
SELECT service_id INTO service FROM panel_service WHERE
specific_da...@domain;
 INSERT INTO panel_order (service, member, description, included, discount,
discharge_date, cessation_date)
VALUES(@service,NEW.member_id,NEW.name,0,0,CURTIME(),CURTIME());
 END IF;
END;

"""

def create_trigger(app, created_models, verbosity, **kwargs):
from django.db import connection
cursor = connection.cursor()
cursor.execute(sql)
signals.post_syncdb.connect(create_trigger, sender=models)


any idea¿¿

thanks!
Marc.


Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py",
line 362, in execute_manager
utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py",
line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
195, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
222, in execute
output = self.handle(*args, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line
351, in handle
return self.handle_noargs(**options)
  File
"/usr/lib/pymodules/python2.6/django/core/management/commands/syncdb.py",
line 99, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive)
  File "/usr/lib/pymodules/python2.6/django/core/management/sql.py", line
205, in emit_post_sync_signal
interactive=interactive)
  File "/usr/lib/pymodules/python2.6/django/dispatch/dispatcher.py", line
166, in send
response = receiver(signal=self, sender=sender, **named)
  File "/var/www/ucp/../ucp/panel/management.py", line 24, in create_trigger
cursor.execute(sql)
  File "/usr/lib/pymodules/python2.6/django/db/backends/util.py", line 19,
in execute
return self.cursor.execute(sql, params)
  File "/usr/lib/pymodules/python2.6/django/db/backends/mysql/base.py", line
84, in execute
return self.cursor.execute(query, args)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 168, in
execute
if not self._defer_warnings: self._warning_check()
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 75, in
_warning_check
warnings = self._get_db().show_warnings()
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 300, in
show_warnings
self.query("SHOW WARNINGS")
_mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't
run this command now")


On Tue, Dec 29, 2009 at 2:49 AM, Marc Aymerich  wrote:

> Hello,
> Is possible to implement mysql triggers with django?? there are some
> documentation about it?
>
> Thanks!!
> Marc
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Mysql triggers with django

2009-12-28 Thread Marc Aymerich
Hello,
Is possible to implement mysql triggers with django?? there are some
documentation about it?

Thanks!!
Marc

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




reverse drops the project from the url returned

2009-12-28 Thread davathar
I'm stuck on a "reverse" problem.  The 'case' view is supposed to
record posted info, then reload the same page.  But it's dropping the
first part of the URL on the redirect and I've not been able to figure
out why.

It should be going to .com/helpdesk/support/case/1/  But it's going
to .com/support/case/1/

I'm sure it's something simple as I've had the problem in the past and
fumbled my way through it.  But I can't find it this time.  Hopefully
the below pasted lines show all the necessary detail.

Anyone see my error?

helpdesk.urls:
urlpatterns = patterns('',
(r'^support/', include('helpdesk.support.urls')),
)

helpdesk.support.urls:
urlpatterns = patterns('helpdesk.support.views',
(r'^case/(?P\d+)/$', 'case',{},'case_url' ),
)

helpdesk.support.views:
def case(request, case):
return HttpResponseRedirect(reverse('case_url', args=(case.id,)))
# Redirect back here after POST

-Shane

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: JavaScript function call

2009-12-28 Thread gilbert F.
Hi Kevin,

Sorry I could not make progress therefore I am considering to use
jQuery. As I never used it, can I have your jQuery code for reference?
You may send to my e-mail gilber...@gamil.com

Thanks so much.


On Dec 28, 9:19 am, "gilbert F."  wrote:
> Hi Kevin,
>
> Thanks so much for your replies. Following your suggestions I have
> moved tag  out of .
>
> 
>