Re: [Trac] Re: Trac 1.0.19 Released

2020-01-07 Thread Roger Oberholtzer
On Wed, Jan 8, 2020 at 8:02 AM Steffen Hoffmann  wrote:

> >Perhaps the Plugins that only work with Python 2 should be moved to a
> >depreciated location? That might make it easier to see which plugins
> >are effected by a move to Python 3.
>
> Why do that much extra effort?
>
> As we did with Trac that had other major, disruptive code changes before, we 
> can just flag/tag hacks with „trac1.6“ or more explicitely „python3“ as coded 
> for Python 3.

I'm sure that you are correct. I just feel that the actual working
support listed for plugins is always a bit iffy at best. One has to
install and see what happens. I'm okay with that.

I guess there are three (at least) things a plugin needs to be tested for:

 * Version of Trac
 * Version of Python
 * Genshi or whatever

What does being Trac 1.4 compatible really mean? Must it also support
Python 3? Or are these independent?



-- 
Roger Oberholtzer

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/CANkOqwMBHU7K%3DoeiDhmA53ej2UypFE02o-_u3YbhsBnM%3DTOMRA%40mail.gmail.com.


Re: [Trac] Re: Trac 1.0.19 Released

2020-01-07 Thread Steffen Hoffmann
Am 7. Januar 2020 11:04:02 MEZ schrieb Roger Oberholtzer 
:
>On Mon, Jan 6, 2020 at 5:23 PM M M  wrote:
>>
>> What is the point of patching ancient versions? Why not just declare
>1.0.x and 1.2.x end of life and focus on 1.4.x and porting to Python3?
>
>I think I agree. I am guessing the biggest reason for not just
>supporting Python 3 is all the plugins that will no longer be usable.
>It's not just Trac itself.
>
>Perhaps the Plugins that only work with Python 2 should be moved to a
>depreciated location? That might make it easier to see which plugins
>are effected by a move to Python 3.

Why do that much extra effort?

As we did with Trac that had other major, disruptive code changes before, we 
can just flag/tag hacks with „trac1.6“ or more explicitely „python3“ as coded 
for Python 3.

Mit freundlichem Gruß

Steffen Hoffmann

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/0A21EFF6-664C-411C-A078-0C5C0AC73DB5%40web.de.


Re: [Trac] How to store a multi object list of dictionary into a table using postgresql

2020-01-07 Thread Jun Omae
On Wed, Jan 8, 2020 at 2:38 PM Velu Narasimman  wrote:
>
> Hi,
>
> I am using MenusPlugin for displaying trac menus as submenus. At one 
> point of implementation we are trying to store a list of dictionary of data 
> that is generated by this menus plugin into postgresql database. Please find 
> the list of dictionary sample below.
>
>
> [{'parent_name': u'top', 'href': u'/auth/dashboard', 'name': u'new_dash', 
> 'active': False, 'visited': True, 'enabled': True, u'order': u'-999', 
> 'label': }, {'parent_name': u'top', 'href': u'/myprojects', 'name': 
> u'allprojects', 'active': True, 'visited': True, 'enabled': True, u'order': 
> u'-998', 'label': }, {'parent_name': u'top', 'href': u'#', 
> 'name': u'alltimesheet', 'children': , 'active': False, 
> 'visited': True, 'enabled': True, u'order': u'-997', 'label': 
> }, {'parent_name': u'top', 'href': u'/myteam', 'name': u'myteam', 
> 'children': , 'active': False, 'visited': True, 'enabled': 
> True, u'order': u'-996', 'label': }, {'name': u'timesheet', 
> 'parent_name': u'top', 'enabled': True, 'label': , 'children': 
> , 'href': '#', 'active': False, 'visited': True, u'order': 
> u'4'}, {'parent_name': 'top', 'name': u'admin', 'enabled': False, 'label': 
> , 'href': '#', 'active': False, 'visited': True, u'order': 
> u'99'}, {'name': u'username', 'parent_name': u'top', 'enabled': True, 
> 'label': , 'children': , 'href': '#', 'active': 
> False, 'visited': True, u'order': u'999'}]
>
> My aim is to store this whole list of dictionary into a table as is. But as 
> you can see some Genshi  and  are present in this, 
> following two methods are failing.
>
> 1. Pickle object
> 2. Json
>
> Method 1: (Pickle)
> -
> pickle_data = cPickle.dumps(menu_dict, -1) # menu_dict is the data that you 
> can see above.
># constructed pickle successfully 
> in this step.
> binary_menu = psycopg2.Binary(pickle_data) # converting pickle to Binary is 
> also done successfully.
># And I hope I can store this data 
> to db as is but for a try I am unpickling the 
># binary data back to it's original form using the below 
> statement
># and that doesn't work!
> cPickle.loads(str(binary_menu)) # this throws some errors as shown below.
>
>
> Below is the error that I ended up with the last line in above chunk
>
>
> Trac detected an internal error:
>
>
> UnpicklingError: invalid load key, '''.

psycopg2.Binary is wrapper class for binary in PostgreSQL and to
generate binary literal.
That instance is unable to use to cPickle.loads.

>>> import cPickle
>>> data = cPickle.dumps({'key':42})
>>> data
"(dp1\nS'key'\np2\nI42\ns."
>>> psycopg2.Binary(data)

>>> print(str(psycopg2.Binary(data)))
'(dp1\012S''key''\012p2\012I42\012s.'::bytea
>>> str(psycopg2.Binary(data))
"'(dp1\\012S''key''\\012p2\\012I42\\012s.'::bytea"

A buffer instance in psycopg2 is retrieved from a binary column.
It is able to cPickle.loads from the buffer instance.

>>> from trac.env import Environment
>>> env = Environment('/var/lib/trac/1.0-postgres')
>>> rows = env.db_query('SELECT %s', (psycopg2.Binary(data),))
>>> rows[0][0]

>>> str(rows[0][0])
"(dp1\nS'key'\np2\nI42\ns."
>>> cPickle.loads(str(rows[0][0]))
{'key': 42}

-- 
Jun Omae  (大前 潤)

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/CAEVLMahOffQxVCys3wCsgOwC4iqLaNccvb-D1Qmnv4WOLz%2Bbnw%40mail.gmail.com.


[Trac] How to store a multi object list of dictionary into a table using postgresql

2020-01-07 Thread Velu Narasimman
 Hi,

I am using MenusPlugin  for 
displaying trac menus as submenus. At one point of implementation we are 
trying to store a list of dictionary of data that is generated by this 
menus plugin into postgresql database. Please find the list of dictionary 
sample below.

   
[{'parent_name': u'top', 'href': u'/auth/dashboard', 'name': u'new_dash', 
'active': False, 'visited': True, 'enabled': True, u'order': u'-999', 
'label': }, {'parent_name': u'top', 'href': u'/myprojects', 'name'
: u'allprojects', 'active': True, 'visited': True, 'enabled': True, u'order'
: u'-998', 'label': }, {'parent_name': u'top', 'href': u'#', 
'name': u'alltimesheet', 'children': , 'active': False, 
'visited': True, 'enabled': True, u'order': u'-997', 'label': }, {'parent_name': u'top', 'href': u'/myteam', 'name': u'myteam', 
'children': , 'active': False, 'visited': True, 'enabled': 
True, u'order': u'-996', 'label': }, {'name': u'timesheet', 
'parent_name': u'top', 'enabled': True, 'label': , 'children': <
Element "ul">, 'href': '#', 'active': False, 'visited': True, u'order': u'4'
}, {'parent_name': 'top', 'name': u'admin', 'enabled': False, 'label': <
Fragment>, 'href': '#', 'active': False, 'visited': True, u'order': u
'99'}, {'name': u'username', 'parent_name': u'top', 'enabled': True, 
'label': , 'children': , 'href': '#', 'active': 
False, 'visited': True, u'order': u'999'}]

My aim is to store this whole list of dictionary into a table as is. But as 
you can see some Genshi  and  are present in this, 
following two methods are failing.

1. Pickle object
2. Json

Method 1: (Pickle)
-
pickle_data = cPickle.dumps(menu_dict, -1) # menu_dict is the data that you 
can see above.
   # constructed pickle 
successfully in this step.
binary_menu = psycopg2.Binary(pickle_data) # converting pickle to Binary is 
also done successfully.
   # And I hope I can store this 
data to db as is but for a try I am unpickling the 
   # binary data back to it's original form using the 
below statement 
   # and that doesn't work!
cPickle.loads(str(binary_menu)) # this throws some errors as shown below.


Below is the error that I ended up with the last line in above chunk 



*Trac detected an internal error: *

UnpicklingError: invalid load key, '''.


I am unable to solve this! so I tried method 2.



Method 2:
---

from psycopg2.extras import Json

menu_dict = {'mainnav': menu_dict}
Json(menu_dict) # by this I am trying to convert entire list of dict into 
some json object and this doesn't work either.


tried one more varient with the default json conversion.

import json
json.dumps(menu_dict) # this produces below error.



*Trac detected an internal error: *

TypeError:  is not JSON serializable



My total aim is to store the first data, that is a list of data into a 
table and retrieve it back.

Help me to solve this.

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/50de0e9c-179b-4584-ba33-54d6ce553307%40googlegroups.com.


Re: [Trac] Re: Trac 1.0.19 Released

2020-01-07 Thread Roger Oberholtzer
On Mon, Jan 6, 2020 at 5:23 PM M M  wrote:
>
> What is the point of patching ancient versions? Why not just declare 1.0.x 
> and 1.2.x end of life and focus on 1.4.x and porting to Python3?

I think I agree. I am guessing the biggest reason for not just
supporting Python 3 is all the plugins that will no longer be usable.
It's not just Trac itself.

Perhaps the Plugins that only work with Python 2 should be moved to a
depreciated location? That might make it easier to see which plugins
are effected by a move to Python 3.

-- 
Roger Oberholtzer

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to trac-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/CANkOqwPey4dd_4qWSYkpB%2BRD6o9AeiD7dJ7NpvSCDDcZb9Z_UA%40mail.gmail.com.